Difference between revisions of "LlGetAgentLanguage"

From Second Life Wiki
Jump to navigation Jump to search
m (added date of release)
 
(One intermediate revision by one other user not shown)
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 ){
Line 49: Line 50:
         }
         }
     }
     }
}</lsl>
}</source>
|spec
|spec
|constants=
|constants=

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 );