Created
February 14, 2021 21:41
-
-
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...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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