Godot Version
v4.7.stable.official [5b4e0cb0f]
Question
I am using a CSV file for storing all of the strings for my game in different locales. What I want to make is a function that takes a RegEx string and returns all the strings (in the current locale), whose keys match the given RegEx. It goes like this:
static func get_all_strings(key_regex: String):
var found_strings: Array[String]
var cur_locale = TranslationServer.get_locale()
var translation = TranslationServer.find_translations(cur_locale, true)[0]
var regex = RegEx.create_from_string(key_regex)
for key in translation.get_message_list():
if regex.search(key):
var translated_key = TranslationServer.translate(key)
if !translated_key.is_empty():
found_strings.append(translated_key)
return found_strings
The problem is: translation that I get from find_translations is OptimizedTranslation. Therefore get_message_list() is always empty. I tried to search a way to get it unoptimized and failed. Is there any workaround?