-
-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change translation to be on a script basis
- Loading branch information
Showing
57 changed files
with
2,341 additions
and
2,054 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class_name Scripts extends RefCounted | ||
|
||
# Simple solution to running some scripts by just running the project. | ||
static func update_translations() -> void: | ||
load("res://godot_only/scripts/update_translations.gd").new() |
File renamed without changes
This file contains 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
File renamed without changes
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
extends RefCounted | ||
|
||
# Don't have a better solution than handling all these different whitespace variations... | ||
const delimiters = { | ||
'TranslationServer.translate("': '")', | ||
'TranslationServer.translate(\n\t\t\t"': '")', | ||
'TranslationServer.translate(\n\t\t\t\t"': '")', | ||
'TranslationServer.translate(\n\t\t\t\t\t"': '")', | ||
"TranslationServer.translate('": "')", | ||
'TranslationServer.translate("""': '""")', | ||
'TranslationServer.translate_plural("': '")', | ||
"TranslationServer.translate_plural('": "')", | ||
'TranslationServer.translate_plural("""': '""")', | ||
} | ||
|
||
var strings: PackedStringArray = PackedStringArray(["translation-credits"]) | ||
|
||
func _init() -> void: | ||
search_directory(ProjectSettings.globalize_path("src")) | ||
update_translations() | ||
|
||
|
||
func search_directory(dir: String) -> void: | ||
for dir_name in DirAccess.get_directories_at(dir): | ||
search_directory(dir.path_join(dir_name)) | ||
|
||
for file_name in DirAccess.get_files_at(dir): | ||
var file_text := FileAccess.get_file_as_string(dir.path_join(file_name)) | ||
for start_delim: String in delimiters: | ||
var end_delim: String = delimiters[start_delim] | ||
var cursor := 0 | ||
while true: | ||
cursor = file_text.find(start_delim, cursor) | ||
if cursor == -1: | ||
break | ||
|
||
var string_start := cursor + start_delim.length() | ||
cursor = file_text.find(end_delim, cursor) | ||
var string := file_text.substr(string_start, cursor - string_start) | ||
if not string in strings: | ||
strings.append(string) | ||
|
||
func update_translations() -> void: | ||
var location := ProjectSettings.globalize_path("translations/GodSVG.pot") | ||
DirAccess.make_dir_recursive_absolute(location) | ||
var fa := FileAccess.open(location, FileAccess.WRITE) | ||
|
||
fa.store_string("#, fuzzy\n") | ||
fa.store_string("msgid \"\"\n") | ||
fa.store_string("msgstr \"\"\n") | ||
fa.store_string("\"Project-Id-Version: GodSVG\\n\"\n") | ||
fa.store_string("\"POT-Creation-Date: \\n\"\n") | ||
fa.store_string("\"PO-Revision-Date: \\n\"\n") | ||
fa.store_string("\"Last-Translator: \\n\"\n") | ||
fa.store_string("\"Language-Team: \\n\"\n") | ||
fa.store_string("\"MIME-Version: 1.0\\n\"\n") | ||
fa.store_string("\"Content-Type: text/plain; charset=UTF-8\\n\"\n") | ||
fa.store_string("\"Content-Transfer-Encoding: 8bit\\n\"\n") | ||
fa.store_string("\"X-Generator: Poedit 3.4.2\\n\"\n") | ||
|
||
for string in strings: | ||
fa.store_string('\nmsgid "%s"\nmsgstr ""\n' % string) | ||
fa = null | ||
|
||
var files := DirAccess.get_files_at(ProjectSettings.globalize_path("translations")) | ||
for file in files: | ||
if file.get_extension() != "po": | ||
continue | ||
|
||
var args := PackedStringArray(["--update", "--quiet", "--verbose", "--backup=off", | ||
ProjectSettings.globalize_path("translations").path_join(file), location]) | ||
OS.execute("msgmerge", args) |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.