I posted a comment to the following thread asking for clarification on an answer, and the author suggested I expand the comment into a formal question.
The response speaks to the benefits of using resources as a modular localization solution. My question is, what is the inherent benefit of using resource files (and a resx manager) versus an interface/class based solution. It seems to me that in a MVC/MVVM type design pattern, the view will be nearly exclusively variable references. If you create an interface for each view, you will have an instant understanding as to whether a view has been fully implemented for a language. This could be implemented as shown below:
Language File:
public interface IMyAppLogin
{
string LoginPrompt { get; }
string ForgotPWLabel { get; }
}
public class Eng : IMyAppLogin
{
public string LoginPrompt => "Please Login";
public string ForgotPWLabel => "Forgot your password?";
}
public class Portuguese : IMyAppLogin
{
public string LoginPrompt => "Login por favor";
public string ForgotPWLabel => "Não lembro o Senha?";
}
Model:
public class MyAppLoginModel
{
IMyAppLogin Lang;
}
Controller:
public class AController
{
MyAppLoginModel m;
public AController(string la)
{
switch(la)
{
case "pt":
m.Lang = new Portuguese();
break;
default:
m.Lang = new Eng();
break;
}
}
}
Finally your view would reference the model to fill in the text.
These language classes could be compartmentalized and made portable in their own Standard .Net Library. If you needed to send it to a translator, you could create an excel template to send externally, and then it would be trivial to create a script that would convert an excel generated .csv into the class format shown below.
Why is the resource method better than this method? Or maybe restated, which is the better method for attacking reusable localization?