Skip to content

Instantly share code, notes, and snippets.

@rambda
Created February 14, 2021 21:41
Show Gist options
  • Select an option

  • Save rambda/9d87fe7fbd4d3b719b01fbb25a66348f to your computer and use it in GitHub Desktop.

Select an option

Save rambda/9d87fe7fbd4d3b719b01fbb25a66348f to your computer and use it in GitHub Desktop.
A resource that automatically exports loaded locales to assign name in that langauge...
tool
extends Resource
class_name LocaleNameList
var data: Dictionary
func _init() -> void:
for locale in TranslationServer.get_loaded_locales():
if not locale in data:
data[locale] = ""
func _get(property):
if property in data:
return data[property]
func _set(property, value):
if property in data:
data[property] = value
property_list_changed_notify()# update inspect
return true
# call once when node selected
func _get_property_list():
var property_list = []
for locale in data:
property_list.append({
"hint": PROPERTY_HINT_NONE,
"usage": PROPERTY_USAGE_DEFAULT,
"name": locale,
"type": TYPE_STRING
})
property_list.append(
{
"hint": PROPERTY_HINT_NONE,
"usage": PROPERTY_USAGE_STORAGE,
"name": "data",
"type": TYPE_DICTIONARY
}
)
return property_list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment