[MonoTouch] Multi-lingual
Nic Wise
nicw at fastchicken.co.nz
Fri Oct 7 06:37:39 EDT 2011
My understanding, and I hope you have an idea of just how wrong this
could be, is that if you use interface builder, you get it for free.
You can design Foo.en.xib and Foo.de.xib and the OS will load the
correct one for you, based on the users stated language preference.
This allows you to do nice things like lay out the form differently if
you need to use a very long word in one lang, and a very short one in
another.
I think Cocoa has things built in for this, as well as tools to manage
it, as this Name.locale.xib etc stuff has been in since OSX 10.0. I
seam to recall a NSLocalizedString, and a quick google supports that:
http://forums.macrumors.com/showthread.php?t=373834
http://stackoverflow.com/questions/1094233/how-to-use-nslocalizedstring-in-ib-iphone-sdk
Now, if you need the user to be able to pick Dutch, even if the phone
is set to German, then I think you are going to have to do it
yourself. But if you just want to match the user's preference (which,
I think, is the best option), then the built in stuff should work
well.
I'd look into what Cocoa provides for you, as I think it's a fairly
well solved problem.
Cheers
N
On Fri, Oct 7, 2011 at 11:20, Danny Pronk <dpronk at probe-asp.eu> wrote:
> Hi Mittchel/Hoi Mittchel(dutch guy here too),
> I was facing exactly the same problem in a project.
> After investigation it turned out that you can't create/write new values in
> those language resource files.
> So I have chosen the following path :
>
> Created a language resource table with sqlite
> Build a function ReadResourceLanguageField(string UIResourceName) that
> returns the value for a specific field
> Inside this function I use NSLocale.PreferredLanguages[0] to determin the
> current language and if it doesn't exist i revert back to a default language
> Everywhere where I set/use values on screen I use the function
> ReadResourceLanguageField("control.propertyname") so if you need to set the
> local version of a label called lblHeader you would use "lblHeader.Text"
> this way it is very clear where you set/fetch what value.
> Last but not least i have build a checksum calculation on a given language
> on changing language i check the checksum with a webservice which returns OK
> (no changes) or replies with a new set of data for that specific language
> which i then replace inside the database, or if it is a new language it will
> create the records in the database. If the language is not available it will
> return unkown and then i revert back to my default language
>
> Hopefully this helps you
> Regards,
> Danny Pronk
>
>
> Van: Mittchel Van Vliet <mittchel at gmail.com>
> Datum: Fri, 7 Oct 2011 11:54:53 +0200
> Aan: <monotouch at lists.ximian.com>
> Onderwerp: [MonoTouch] Multi-lingual
>
> Hello everybody,
> For an application that I'm going to develop I have to keep two different
> languages in mind. These two might turn into more further in the future.
> I've created an settings view where it's possible to select the Language
> which gets saved in the local database.
> But how do I arrange that if someone selects Dutch and saves it that
> everything (UI/Text) turns into that language?
> Regards,
> Mittchel
> _______________________________________________ MonoTouch mailing list
> MonoTouch at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/monotouch
> _______________________________________________
> MonoTouch mailing list
> MonoTouch at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/monotouch
>
>
--
Nic Wise
t. +44 7788 592 806 | @fastchicken | http://www.linkedin.com/in/nicwise
b. http://www.fastchicken.co.nz/
mobileAgent (for FreeAgent): get your accounts in your pocket.
http://goo.gl/IuBU
Trip Wallet: Keep track of your budget on the go: http://goo.gl/ePhKa
London Bike App: Find the nearest Boris Bike, and get riding! http://goo.gl/Icp2
More information about the MonoTouch
mailing list