Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Localize language

Enthusiast ,
Jan 29, 2025 Jan 29, 2025

I've reached a dead end
I would like to make the panel change the language based on the country of use,
unfortunately I stopped and I can't go on,
up to now I have managed to set 2 languages,
I would like to set another 2 or 3
this is my starting script.

 const host = require('uxp').host;
    const locale = host.uiLocale;
    if (locale == "en_US" ){
        english();
    }else{
        france();
    }

 

I tried this method but had no luck

 

    const host = require('uxp').host;
    const locale = host.uiLocale;
    if (locale == "en_US" ){
        english();
    }else{
        france();
 }else{
espana();
}

 

I hope there is a solution

TOPICS
Actions and scripting
385
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Community Expert , Jan 29, 2025 Jan 29, 2025

I am not up to speed with USP Scripting but you seem to have one if-clause and two else-clauses.

So the numbers don’t seem to add up and you may need a second if-clause to verify »frenchness« before »defaulting« to Spanish. 

 

Edit: Alternatively you could try using a switch-clause. 

Translate
Enthusiast , Jan 29, 2025 Jan 29, 2025

 

 

if (locale == "en_US") {
    english();
} else if (locale == "it_IT") {
    italy();
} else if (locale == "es_ES") {
    spanish();
} else {
    defaultLanguage();
}

}

@pfaffenbichler
thanks to your help I solved it this way
thanks 

Translate
Adobe
Community Expert ,
Jan 29, 2025 Jan 29, 2025

I am not up to speed with USP Scripting but you seem to have one if-clause and two else-clauses.

So the numbers don’t seem to add up and you may need a second if-clause to verify »frenchness« before »defaulting« to Spanish. 

 

Edit: Alternatively you could try using a switch-clause. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jan 29, 2025 Jan 29, 2025

I tried this way but it doesn't work

    const host = require('uxp').host;
    const locale = host.uiLocale;
    if (locale == "en_US" ){
        english();
    }else{
        france();
 }
if (locale == "es_ES" ){
espana();
}
}

 

do you have an example of how to set a second if

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jan 29, 2025 Jan 29, 2025
LATEST

 

 

if (locale == "en_US") {
    english();
} else if (locale == "it_IT") {
    italy();
} else if (locale == "es_ES") {
    spanish();
} else {
    defaultLanguage();
}

}

@pfaffenbichler
thanks to your help I solved it this way
thanks 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines