Difference between revisions of "LlGetAgentLanguage"

From Second Life Wiki
Jump to navigation Jump to search
m
 
(10 intermediate revisions by 6 users not shown)
Line 5: Line 5:
|p1_type=key|p1_name=avatar|p1_desc
|p1_type=key|p1_name=avatar|p1_desc
|return_type=string
|return_type=string
|return_text=that is the language code of the preferred interface language of the user '''avatar'''.  
|return_text=that is the language code of the preferred interface language of the user {{LSLP|avatar}}.  
|func_desc
|func_desc
|func_footnote
|func_footnote
Line 15: Line 15:
*Viewers can specify other arbitrary language strings with the 'InstallLanguage' debug setting.  For example, launching the viewer with "--set InstallLanguage american" results this function returning 'american' for the avatar. {{Jira|VWR-12222}}
*Viewers can specify other arbitrary language strings with the 'InstallLanguage' debug setting.  For example, launching the viewer with "--set InstallLanguage american" results this function returning 'american' for the avatar. {{Jira|VWR-12222}}
**If the viewer supplies a multiline value, the simulator will only accept the first line and ignore all others. {{Jira|SVC-5503}}
**If the viewer supplies a multiline value, the simulator will only accept the first line and ignore all others. {{Jira|SVC-5503}}
|examples=<lsl>
*Older viewers may return "en-us" instead of "en".
|examples=<source lang="lsl2">
default{
default{
     touch_start( integer num_detected ){
     touch_start( integer num_detected ){
        string name;
        string language;
       
         //-- loop through all detected touches
         //-- loop through all detected touches
         for (num_detected -= 1; num_detected > -1; num_detected -= 1 ){
         for (num_detected -= 1; num_detected > -1; num_detected -= 1 ){
             name = llDetectedName( num_detected );
             key agent = llDetectedKey( num_detected );
             language = llGetAgentLanguage( llDetectedKey( num_detected ) );
            string name = llGetDisplayName( agent );
             string language = llGetAgentLanguage( agent );
 
            if (("" == name) || ("???" == name))
                name = llDetectedName( num_detected );


             //-- PUBLIC_CHANNEL is 0
             //-- PUBLIC_CHANNEL is 0
Line 35: Line 37:
             }else if (language == "de"){
             }else if (language == "de"){
                 llSay( PUBLIC_CHANNEL, "Hallo, " + name + "!" );
                 llSay( PUBLIC_CHANNEL, "Hallo, " + name + "!" );
            }else if (language == "en"){ //-- returned by some TPVs
                llSay( PUBLIC_CHANNEL, "Hello, " + name + "!" );
             }else if (language == "pt"){
             }else if (language == "pt"){
                 llSay( PUBLIC_CHANNEL, "Olá!, " + name + "!" );
                 llSay( PUBLIC_CHANNEL, "Olá!, " + name + "!" );
Line 41: Line 45:
             }else if (language == "zh"){
             }else if (language == "zh"){
                 llSay( PUBLIC_CHANNEL, "你好啊, " + name + "!" );
                 llSay( PUBLIC_CHANNEL, "你好啊, " + name + "!" );
             }else{ //-- Default to english if language is unrecognized \ not provided.
             }else{ //-- Default to 'en-us' if language is unrecognized / not provided.
                 llSay( PUBLIC_CHANNEL, "Hi there, " + name + "!" );
                 llSay( PUBLIC_CHANNEL, "Hi there, " + name + "!" );
             }
             }
         }
         }
     }
     }
}</lsl>
}</source>
|spec
|spec
|constants=
|constants=
Line 64: Line 68:
|history=*Introduced in {{SVN|568|rev=88085|branch=Release|anchor=file33|date=Wednesday, 21 May 2008}}
|history=*Introduced in {{SVN|568|rev=88085|branch=Release|anchor=file33|date=Wednesday, 21 May 2008}}
*Modified to only return the first line with {{Jira|SVC-5503}}
*Modified to only return the first line with {{Jira|SVC-5503}}
*Date of Release [[ Release_Notes/Second_Life_Release/1.21 | 16-10-2008 ]]
|cat1=Avatar
|cat1=Avatar
|cat2
|cat2

Latest revision as of 15:05, 15 July 2018

Summary

Function: string llGetAgentLanguage( key avatar );
0.0 Forced Delay
10.0 Energy

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)
If the viewer is set to "System Default" the possible return may not be in this list. See List of ISO 639-1 codes for reference.

The value can also be modified by directly editing the settings.xml file or with debug settings. So the value returned by llGetAgentLanguage may not be an ISO 639-1 value at all.

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.
  • Viewers can specify other arbitrary language strings with the 'InstallLanguage' debug setting. For example, launching the viewer with "--set InstallLanguage american" results this function returning 'american' for the avatar. VWR-12222
    • If the viewer supplies a multiline value, the simulator will only accept the first line and ignore all others. SVC-5503
  • Older viewers may return "en-us" instead of "en".

Examples

default{
    touch_start( integer num_detected ){
        //-- loop through all detected touches
        for (num_detected -= 1; num_detected > -1; num_detected -= 1 ){
            key agent = llDetectedKey( num_detected );
            string name = llGetDisplayName( agent );
            string language = llGetAgentLanguage( agent );

            if (("" == name) || ("???" == name))
                name = llDetectedName( num_detected );

            //-- PUBLIC_CHANNEL is 0
            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 == "en"){ //-- returned by some TPVs
                llSay( PUBLIC_CHANNEL, "Hello, " + 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 + "!" );
            }else{ //-- Default to 'en-us' if language is unrecognized / not provided.
                llSay( PUBLIC_CHANNEL, "Hi there, " + name + "!" );
            }
        }
    }
}

Deep Notes

History

Signature

function string llGetAgentLanguage( key avatar );