Home > Software engineering >  Make a reference to a strings file from a stringsdict
Make a reference to a strings file from a stringsdict

Time:11-24

I have a strings file named Localizable.strings which has all the strings for my app and I have another stringsdict file which contains every plurals strings.

My stringsdict file looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>GLOBAL_JOUR</key>
    <dict>
        <key>NSStringLocalizedFormatKey</key>
        <string>%#@VARIABLE@</string>
        <key>VARIABLE</key>
        <dict>
            <key>NSStringFormatSpecTypeKey</key>
            <string>NSStringPluralRuleType</string>
            <key>NSStringFormatValueTypeKey</key>
            <string>u</string>
            <key>zero</key>
            <string>0 day</string>
            <key>one</key>
            <string>1 day</string>
            <key>other</key>
            <string>%u days</string>
        </dict>
    </dict>
</dict>
</plist>

Now what I'd like to do is to basically have the strings "day" and "days" in my strings file and have a reference to it from my stringsdict file so I don't need to duplicate plural strings. Does anyone know a way to do that? I can't find anything in the documentation.

CodePudding user response:

Load a value from your strings dict file. Use the fetched string in a call to NSLocalizedString() and pass in the string you loaded as the key.

  • Related