Difference between revisions of "LlGetAgentLanguage"

From Second Life Wiki
Jump to navigation Jump to search
m
 
(14 intermediate revisions by 7 users not shown)
Line 1: Line 1:
{{Issues/VWR-12222}}{{LSL_Function/avatar|avatar|sim=*}}{{LSL_Function
{{LSL_Function
|inject-2={{LSL_Function/avatar|avatar|sim=*}}{{Issues/VWR-12222}}{{Issues/SVC-5503}}
|func_id=336|func_sleep=0.0|func_energy=10.0
|func_id=336|func_sleep=0.0|func_energy=10.0
|func=llGetAgentLanguage
|func=llGetAgentLanguage
|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 12: Line 13:
*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>
*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}}
default
**If the viewer supplies a multiline value, the simulator will only accept the first line and ignore all others. {{Jira|SVC-5503}}
{
*Older viewers may return "en-us" instead of "en".
     touch_start(integer num_detected)
|examples=<source lang="lsl2">
    {
default{
        key id = llDetectedKey(0);
     touch_start( integer num_detected ){
        string name = llDetectedName(0);
        //-- loop through all detected touches
        string language = llGetAgentLanguage(id);
        for (num_detected -= 1; num_detected > -1; num_detected -= 1 ){
            key agent = llDetectedKey( num_detected );
            string name = llGetDisplayName( agent );
            string language = llGetAgentLanguage( agent );


        //if no information sent by viewer, set back to default English
            if (("" == name) || ("???" == name))
        if (language == "") language = "en-us";
                name = llDetectedName( num_detected );


        // PUBLIC_CHANNEL is 0
            //-- PUBLIC_CHANNEL is 0
        if (language == "en-us")
            if (language == "es"){
            llSay(PUBLIC_CHANNEL, "Hi there, " + name + "!");
                llSay( PUBLIC_CHANNEL, "¡Hola, " + name + "!" );
        else if (language == "es")
            }else if (language == "fr"){
            llSay(PUBLIC_CHANNEL, "¡Hola, " + name + "!");
                llSay( PUBLIC_CHANNEL, "Salut, " + name + " !" );
        else if (language == "fr")
            }else if (language == "ja"){
            llSay(PUBLIC_CHANNEL, "Salut, "+name+" !");
                llSay( PUBLIC_CHANNEL, "やあ、 " + name + "" );
        else if (language == "ja")
            }else if (language == "de"){
            llSay(PUBLIC_CHANNEL, "やあ、 " + name + "");
                llSay( PUBLIC_CHANNEL, "Hallo, " + name + "!" );
        else if (language == "de")
            }else if (language == "en"){ //-- returned by some TPVs
            llSay(PUBLIC_CHANNEL, "Hallo, " + name + "!");
                llSay( PUBLIC_CHANNEL, "Hello, " + name + "!" );
        else if (language == "pt")
            }else if (language == "pt"){
            llSay(PUBLIC_CHANNEL, "Olá!, " + name + "!");
                llSay( PUBLIC_CHANNEL, "Olá!, " + name + "!" );
        else if (language == "ko")
            }else if (language == "ko"){
            llSay(PUBLIC_CHANNEL, "안녕하세요, " + name + "!");
                llSay( PUBLIC_CHANNEL, "안녕하세요, " + name + "!" );
        else if (language == "zh")
            }else if (language == "zh"){
            llSay(PUBLIC_CHANNEL, "你好啊, " + name + "!");
                llSay( PUBLIC_CHANNEL, "你好啊, " + name + "!" );
            }else{ //-- Default to 'en-us' if language is unrecognized / not provided.
                llSay( PUBLIC_CHANNEL, "Hi there, " + name + "!" );
            }
         }
         }
     }
     }
}
}</source>
</lsl>
|spec
|spec
|constants={{LSL Constants/Language}}
|constants=
{{{!}} cellspacing="0" cellpadding="0"
{{!}}- valign='top'
{{!}}
{{LSL Constants/Language}}
{{!}}If the viewer is set to "System Default" the possible return may not be in this list. See [http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes 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.
{{!}}}
|helpers
|helpers
|also_functions
|also_functions
Line 52: Line 66:
|also_events
|also_events
|notes
|notes
|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}}
*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 );