addressed some synchronization issues in i18n to fix a crash with GDC 4.9.0; removed some minor unused features

This commit is contained in:
Donny Viszneki 2014-08-14 05:18:06 -07:00
parent 09953b2057
commit 9f4b8e47eb
1 changed files with 9 additions and 14 deletions

View File

@ -94,21 +94,17 @@ struct UIString {
alias value this; alias value this;
} }
public __gshared UIStringTranslator i18n = new UIStringTranslator(); shared UIStringTranslator i18n;
//static shared this() { shared static this() {
// i18n = new UIStringTranslator(); i18n = new shared UIStringTranslator();
//} }
class UIStringTranslator { synchronized class UIStringTranslator {
private UIStringList _main; private UIStringList _main;
private UIStringList _fallback; private UIStringList _fallback;
private string[] _resourceDirs; private string[] _resourceDirs;
/// get i18n resource directory
@property string[] resourceDirs() { return _resourceDirs; }
/// set i18n resource directory
@property void resourceDirs(string[] dirs) { _resourceDirs = dirs; }
/// looks for i18n directory inside one of passed dirs, and uses first found as directory to read i18n files from /// looks for i18n directory inside one of passed dirs, and uses first found as directory to read i18n files from
string[] findTranslationsDir(string[] dirs ...) { void findTranslationsDir(string[] dirs ...) {
_resourceDirs.length = 0; _resourceDirs.length = 0;
import std.file; import std.file;
foreach(dir; dirs) { foreach(dir; dirs) {
@ -118,7 +114,6 @@ class UIStringTranslator {
_resourceDirs ~= path; _resourceDirs ~= path;
} }
} }
return _resourceDirs;
} }
/// convert resource path - append resource dir if necessary /// convert resource path - append resource dir if necessary
@ -140,8 +135,8 @@ class UIStringTranslator {
} }
this() { this() {
_main = new UIStringList(); _main = new shared UIStringList();
_fallback = new UIStringList(); _fallback = new shared UIStringList();
} }
/// load translation file(s) /// load translation file(s)
bool load(string mainFilename, string fallbackFilename = null) { bool load(string mainFilename, string fallbackFilename = null) {
@ -168,7 +163,7 @@ class UIStringTranslator {
} }
/// UI string translator /// UI string translator
class UIStringList { private shared class UIStringList {
private dstring[string] _map; private dstring[string] _map;
/// remove all items /// remove all items
void clear() { void clear() {