Cannot iterate non-resource files in the directory in the build

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By TML

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.

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.

Calinou | 2020-05-18 10:20

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.

TML | 2020-05-19 10:31