Translate strings between languages.
Translation support provides the ability to use a special provider to return strings based on the language of the user accessing the API or dashboard.
Navigate to Platform \ Translations in the Admin Console to define language strings.
Once you have created the language, you can begin to add strings to it by click Edit. The Key will be used within your scripts and will return the value. The value will change depending on the language.
To use a string, you will take advantage of the new
$tl:provider. Using this provider in your scripts will automatically translate the key to the string for the user's language.
For example, you would use the variable like this.
The returned value, when the user's locale is en, will be
Strings are currently available in APIs and dashboards automatically and in scripts when setting the
Note that the
$t:provider is also available but due to conflicts with the FileSystem provider and mapped T: drives, we suggest using the
$tl:provider instead. The
$t:provider will be mapped on machines that do not already have a T: drive mapped.
PowerShell Universal selects the user's language by examining the
Accept-Languageheader in the HTTP request when user's visit the dashboard page or make an API call. If you want to set a language when running a script, you will need to set the
$LanguageIDvariable to the language you wish to return.
If a language is not defined for the specific language ID (e.g.
en-US), then PowerShell Universal will attempt to locate the next best language. For example, this would then look for
If no language can be found, then the server-wide fallback language will be used. If this hasn't been defined,
enwill be used. You can specify this the fallback language in Settings \ General \ Platform.
If no language can be found for the specified key, the key will be returned.
Language files are generated in the translations folder within the repository. Each language will have a
.ps1file named after the language ID.
New-PSUTranslationis used to define the language and set the strings.
It may be desired to edit language files in this way to accommodate copy and pasting keys between language files.