Ege Aydın
Ege Aydın

Reputation: 1081

Xamarin Forms: Resource strings

I have been developing mobile apps with Xamarin for six months and Xamarin Forms is the only way that I did it. Two days ago I came across to an article that suggested me to use recourse strings via xml instead of hardcoding them. I researched it for android and general idea leaded me to use recourse strings.

My question is:

I created an abstract class called BaseLang in portable library which looks similar like this:

public abstract class BaseLang
{
     public abstract string Text { get; }
}

And for every language i create,

public class EngLang : BaseLang
{
    public override string Text { get { return "Welcome"; } }
}

And I declare my EngLang class as a static variable at the first time the app is built and use my strings with it. My actual question is, is this ok or I should use resource strings and use dependency injection to call them?

Upvotes: 1

Views: 1854

Answers (1)

Alessandro Caliaro
Alessandro Caliaro

Reputation: 5768

I think you have to take a look to resx files. https://github.com/xamarin/xamarin-forms-samples/tree/master/TodoLocalized

Upvotes: 1

Related Questions