Programmatically get list of allowed locales?

Does anyone know of a way to access the list of allowed values for localization codes? I’m aware this is given as a list in the API docs, but I’m looking to get it programmatically.

For my plugin’s purposes, I sometimes need to generalize from a specific code (e.g., “en-US”) to a general code (“en”), to use as a key for localization dictionaries, but I don’t want to do this in the case when Sketchup allows more than one specific variant for that language (e.g., “zh-CN” and “zh-TW”).

The #os_language and #get_locale methods only seem to let you query the current language.

SketchUp is a single-language application (each download includes only one language and English as fallback), and some binaries are specific to a language (e.g. due to old old Windows code pages). I am not sure if these are now moved to the Resources folder and I am not sure whether “merging” languages into one installation is now safe without crashes. SketchUp advertises to Ruby extensions the locale of the SketchUp installation, even if the system locale is different (even if the extensions supports the system locale).

However, since a SketchUp installation includes only one locale, there has been no use case to return a list of supported locales. The list of supported locales would be comprised of the language-specific downloads, of which logically a single release should not know how many others there are (supported languages may be added/removed).

Thanks for the reply. It is exactly because of the tendency for supported languages to change that I’d like to be able to query this, but your reasoning makes sense, as to why this is unlikely to be supported. I’ll find another way…

It would make sense to have this documented, what locales were available for various versions.

Can you file ticket in our issue tracker? Issues · SketchUp/api-issue-tracker · GitHub

Sure, I can file the ticket. Do you mean just to make sure it’s included in the API docs? There is already a list of acceptable return values mentioned under #get_locale.

1 Like

Which is out of date.

A Swedish ("sv") build is also available, but I cannot find out when it was added as the Release Notes are no longer searchable.