3

I've build an iOS application, and translated the application to English and Swedish. The problem I'm facing is that one word in English can have two different meaning (translations) in Swedish. So now I have the English word as the key and value. I want to be able to have one key, which I can call whatever I want and set the English value for it as well as the Swedish value, in this way I can translate it to Swedish with two different words and keeping the same word for English.

How can I achieve this guys? Thank you.

EDIT:

// this can be "Kommentar" or "Kommentera" in Swedish (2 different words)
NSLocalizedString(@"Comment", @"Comment") 

What I would like to have is:

NSLocalizedString(@"Comment_adj", @"Comment_adj") // En: Comment, Swe: Kommentar
NSLocalizedString(@"Comment_verb", @"Comment_verb") // En: Comment, Swe: Kommentera

Is it more clear now?

Carnal
  • 21,744
  • 6
  • 60
  • 75
  • 1
    It's quite hard to understand what you want. Could you add some code to give an example of what you'd want to be able to do? – joerick May 28 '13 at 10:16
  • This is exactly why you shouldn't translate word by word. – borrrden May 28 '13 at 10:21
  • Okey, I'll make an edit – Carnal May 28 '13 at 10:24
  • 2
    This is a valid question - it's not about word-for-word translations, it's about the same "localisable string" (which can be a single word) having multiple translations in different contexts, therefore requiring a different "key" - iOS uses the default language as the "key" which limits the number of localisable strings, because for example "Post" - to post something - and "Post" - as in fence-post become a single "localisable string" when it should really be two separate strings. – jhabbott May 28 '13 at 10:40
  • +1 Good valid question. I guess that a bit too general title (`**Best practice** of localizing`) is misleading for people not quite familiar with iOS -- hence many downvotes. – Ilya Kurnosov May 28 '13 at 11:21

1 Answers1

3

The way to resolve this is to give your localized strings some context using NSLocalizedStringFromTable(<#key#>, <#tbl#>, <#comment#>).

For example:

NSLocalizedStringFromTable(@"Post", @"SubmitScreen", @"The button text for the post button on the submit screen");
NSLocalizedStringFromTable(@"Post", @"FenceDiagram", @"The label for the fence-post on the diagram of the fence"); 
jhabbott
  • 18,461
  • 9
  • 58
  • 95
  • I'm using Localization Manager application to translate my words. I generated the new localized file with genstrings but it didn't update. Is their anything out of the ordinary I need to do mate? – Carnal May 28 '13 at 10:56
  • Read how genstrings works here: http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/LoadingResources/Strings/Strings.html and also remember it parses the source code so I think your table names should be explicit, i.e. @"Table" rather than a macro or function call. – jhabbott May 28 '13 at 11:15