Difference between revisions of "LlGetAgentLanguage"

From Second Life Wiki
Jump to navigation Jump to search
m (max time period to reasonably expect with more accuracy, as observed in busy sim)
m
Line 12: Line 12:
*New language/variant values may be added later. Scripts may need to be prepared for unexpected values.
*New language/variant values may be added later. Scripts may need to be prepared for unexpected values.
*If the viewer is set to "System Default" the possible return may be outside the list given above. see [http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes List of ISO 639-1 codes] for reference.
*If the viewer is set to "System Default" the possible return may be outside the list given above. see [http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes List of ISO 639-1 codes] for reference.
|examples=<lsl>default {
|examples=<lsl>
    state_entry() {
default
    }
{
     touch_start(integer n) {
     touch_start(integer num_detected)
         integer i;
    {
        for(i=0;i<n;i++) {
         key id = llDetectedKey(0);
            string name=llDetectedName(i);
        string name = llDetectedName(0);
            string lang=llGetAgentLanguage(llDetectedKey(i));
        string language = llGetAgentLanguage(id);
            if(lang=="") lang="en-us"; // Default to English.
 
            if(lang=="en-us") {
        //if no information sent by viewer, set back to default English
                llSay(0,"Hi there, "+name+"!");
        if (language == "") language = "en-us";
            }else if(lang=="es") {
 
                llSay(0,"¡Hola, "+name+"!");
        // PUBLIC_CHANNEL is 0
            }else if(lang=="fr") {
        if (language == "en-us")
                llSay(0,"Salut, "+name+" !");
            llSay(PUBLIC_CHANNEL, "Hi there, " + name + "!");
            }else if(lang=="ja") {
        else if (language == "es")
                llSay(0,"やあ、 "+name+"!");
            llSay(PUBLIC_CHANNEL, "¡Hola, " + name + "!");
            }else if(lang=="de") {
        else if (language == "fr")
                llSay(0,"Hallo, "+name+"!");
            llSay(PUBLIC_CHANNEL, "Salut, "+name+" !");
            }else if(lang=="pt") {
        else if (language == "ja")
                llSay(0,"Olá!, "+name+"!");
            llSay(PUBLIC_CHANNEL, "やあ、 " + name + "!");
            }else if(lang=="ko") {
        else if (language == "de")
                llSay(0,"안녕하세요, "+name+"!");
            llSay(PUBLIC_CHANNEL, "Hallo, " + name + "!");
            }else if(lang=="zh") {
        else if (language == "pt")
                llSay(0,"你好啊, "+name+"!");
            llSay(PUBLIC_CHANNEL, "Olá!, " + name + "!");
            }
        else if (language == "ko")
            llSay(PUBLIC_CHANNEL, "안녕하세요, " + name + "!");
        else if (language == "zh")
            llSay(PUBLIC_CHANNEL, "你好啊, " + name + "!");
         }
         }
     }
     }

Revision as of 08:28, 26 January 2012

Summary

Function: string llGetAgentLanguage( key avatar );

Returns a string that is the language code of the preferred interface language of the user avatar.

• key avatar avatar UUID that is in the same region

Return Description
"en" English
"da" Dansk (Danish)
"de" Deutsch (German)
"es" Español (Spanish)
"fr" Français (French)
"it" Italiano (Italian)
"hu" Magyar (Hungarian)
"nl" Nederlands (Dutch)
"pl" Polski (Polish)
"pt" Portugués (Portuguese)
"ru" Русский (Russian)
"tr" Türkçe (Turkish)
"uk" Українська (Ukrainian)
"zh" 中文 (简体) (Chinese)
"ja" 日本語 (Japanese)
"ko" 한국어 (Korean)

Caveats

  • If the user has "Share language with objects" disabled then this function returns an empty string.
  • During a 1-5 seconds period after which an agent is logging in, this function will return an empty string as well, until the viewer sends the data to the simulator.
  • Users may prefer to see the client interface in a language that is not their native language, and some may prefer to use objects in the native language of the creator, or dislike low-quality translations. Consider providing a manual language override when it is appropriate.
  • New language/variant values may be added later. Scripts may need to be prepared for unexpected values.
  • If the viewer is set to "System Default" the possible return may be outside the list given above. see List of ISO 639-1 codes for reference.

Important Issues

~ All Issues ~ Search JIRA for related Bugs
   [Won't Fix] llGetAgentLanguage() returns "en", not "en-us" -- Bug or (new) feature?

Examples

<lsl> default {

   touch_start(integer num_detected)
   {
       key id = llDetectedKey(0);
       string name = llDetectedName(0);
       string language = llGetAgentLanguage(id);
       //if no information sent by viewer, set back to default English
       if (language == "") language = "en-us";
       // PUBLIC_CHANNEL is 0
       if (language == "en-us")
           llSay(PUBLIC_CHANNEL, "Hi there, " + name + "!");
       else if (language == "es")
           llSay(PUBLIC_CHANNEL, "¡Hola, " + name + "!");
       else if (language == "fr")
           llSay(PUBLIC_CHANNEL, "Salut, "+name+" !");
       else if (language == "ja")
           llSay(PUBLIC_CHANNEL, "やあ、 " + name + "!");
       else if (language == "de")
           llSay(PUBLIC_CHANNEL, "Hallo, " + name + "!");
       else if (language == "pt")
           llSay(PUBLIC_CHANNEL, "Olá!, " + name + "!");
       else if (language == "ko")
           llSay(PUBLIC_CHANNEL, "안녕하세요, " + name + "!");
       else if (language == "zh")
           llSay(PUBLIC_CHANNEL, "你好啊, " + name + "!");
       }
   }

}

</lsl>

Deep Notes

History

All Issues

~ Search JIRA for related Issues
   [Won't Fix] llGetAgentLanguage() returns "en", not "en-us" -- Bug or (new) feature?

Signature

function string llGetAgentLanguage( key avatar );