Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Yes, but it's not what you think.</p> <p>You can take a strings file and load it into an <code>NSString</code>, and then transform it into a dictionary using <a href="http://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/doc/uid/20000154-propertyListFromStringsFileFormat" rel="noreferrer"><code>-[NSString propertyListFromStringsFileFormat]</code></a>.</p> <p>This will provide you with a way to store your custom-translated strings in-memory.</p> <p>As for actually using that, you'll have to define custom translation functions. IE, you can't use <code>NSLocalizedString()</code> and friends any more. Fortunately, <code>genstrings</code> (the utility used for generating strings files) lets you specify <a href="http://www.manpagez.com/man/1/genstrings/" rel="noreferrer">custom function names</a>:</p> <pre><code>genstrings -s "JPLocalizedString" ... </code></pre> <p>This means that in code, you can define:</p> <pre><code>NSString* JPLocalizedString(NSString *key, NSString *comment) { return [myLoadedStrings objectForKey:key]; } </code></pre> <p>As well as <code>JPLocalizedStringFromTable()</code>, <code>JPLocalizedStringFromTableInBundle()</code>, <code>JPLocalizedStringWithDefaultValue()</code>. <code>genstrings</code> will pick up all of those. (In other words, just because <code>NSLocalizedString</code> is a macro doesn't mean your version has to be)</p> <p>If you do this and use these <code>JPLocalizedString</code> variants, then <code>genstrings</code> will still generate your strings files for you (providing you use the <code>-s</code> flag).</p> <p>Once these functions are called, you can use whatever lookup mechanism you want, defaulting back to the <code>NSLocalizedString</code> versions if you can't find anything.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload