0 votes

It worked when launching the game in the editor, but it doesn't work when launching a build-version.
The directory has been added to the Filters to export non-resource files or folders and the file names can be seen by opening the .pck file via Notepad.

- res://Locales/en-us/Server.json
- res://Locales/en-us/Player.json
- res://Locales/en-us/User.json
- res://Locales/en-us/Command.json

Filters to export non-resource files or folders:
Locales/*, *.json


string path = "res://Locales/en-us/";
Directory dir = new Directory();
dir.ListDirBegin(true, true);

string file = "";
do {
    file = dir.GetNext();
    if (file.EndsWith(".json")) {
        GD.Print(path + file);
} while (file != "");

It outputs names of all the files in the target directory in the editor, and nothing in the built game.

in Engine by (14 points)

Godot has built-in localization facilities using CSV or gettext, why not use those instead?

Either way, directories aren't listable in an exported project because the virtual PCK filesystem doesn't contain actual directories. To solve this, you have to include a text file that lists all files in the directory in the exported project (and red from it), or copy the Locales directory besides the exported executable and read it using the Directory class.

Because the server-side program uses json files to define text strings. I can just copy the json file to update the client language files instead of using the localization facilities of Godot.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.