あなたのスタートはかなり良かったです。 LocBamlを使用することはあまりにも複雑すぎました。だから、私は何かを簡単に見つけなければなりませんでした。ここでは解決策があります:まず、リソース.resxファイルを作成する必要があります(このステップはすでにおこなわれています)。リソースファイルからすべての文字列を取得する簡単な方法は、辞書に格納することです。あなたは、このメソッドを使用してそれを行うことができます。
public Dictionary<string, string> ApplicationStrings(string locale)
{
Dictionary<string, string> result = new Dictionary<string, string>();
ResourceManager manager = null;
// Here is two locales (custom and english locale), but you can use more than two if there's a need
if (locale == "Your locale")
{
manager = new ResourceManager(typeof(your_locale_resource_file));
}
else
{
manager = new ResourceManager(typeof(ApplicationStrings_en));
}
ResourceSet resources = manager.GetResourceSet(CultureInfo.CurrentCulture, true, true);
IDictionaryEnumerator enumerator = resources.GetEnumerator();
while (enumerator.MoveNext())
{
result.Add((string)enumerator.Key, (string)enumerator.Value);
}
return result;
}
あなたは、このメソッドの結果として、メインウィンドウのDataContextのを設定し、辞書にすべてのあなたの文字列をバインドする必要があります。 バインディング例:
Text="{Binding [YourKey]}"
あなたは、このメソッドを呼び出した後、いつでもどこでもあなたが欲しいのDataContextを変更することができます。データバインディングのおかげで、ランタイムで非常にうまく動作します。 私はこのソリューションが最高ではないことは保証されていますが、簡単な方法で動作しています。 私はそれが助けてくれることを願っています。