mac-cain13 / R.swift

Strong typed, autocompleted resources like images, fonts and segues in Swift projects
MIT License
9.49k stars 760 forks source link

Warnings with .string and .stringdict #526

Closed mikhail-muzhev closed 5 years ago

mikhail-muzhev commented 5 years ago

I'm using .string and .stringdict files for localisation. Everything works perfect, but I have two warnings:

[R.swift] Strings file 'Localizable' is missing translations for keys: <.string keys>
[R.swift] Strings file 'Localizable' is missing translations for keys: <.stringdict keys>

As I understood, R.swift is generating localised strings from both of these files and it can't find ".string keys" inside ".stringdict" file, and ".stringdict keys" inside ".string" file. Of course there are different keys inside these files. So how could I resolve these warnings???

mac-cain13 commented 5 years ago

Are the mentioned keys available in all translations? Seems that R.swift thinks they are missing.

mikhail-muzhev commented 5 years ago

Yes. R.swift thinks that .string and .stringdict are from different localisation.

tomlokhorst commented 5 years ago

It should definitely be possible to have different strings in a .strings file and a .stringsdict file. For example, we do this in the ResourceApp project in this repo.

Can you provide a stripped down example of this issue for us to reproduce?

mikhail-muzhev commented 5 years ago

.string

"ok" = "ok";
"error" = "Ошибка";
"notifications_forbidden_by_user" = "Notifications forbidden by user";
"skip" = "Пропустить";
"next" = "Далее";
"begin_work" = "Начать работу!";
"sec" = "сек";
"yes" = "Да";
"cancel" = "Отмена";
"unknown_error" = "Неизвестная ошибка";
"payment" = "Оплата";
"delete" = "Удалить";

.stringdict

<?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>documents</key>
    <dict>
        <key>NSStringLocalizedFormatKey</key>
        <string>Документ%#@Variable@</string>
        <key>Variable</key>
        <dict>
            <key>NSStringFormatSpecTypeKey</key>
            <string>NSStringPluralRuleType</string>
            <key>NSStringFormatValueTypeKey</key>
            <string>d</string>
            <key>zero</key>
            <string>ов</string>
            <key>one</key>
            <string></string>
            <key>two</key>
            <string>а</string>
            <key>few</key>
            <string>а</string>
            <key>many</key>
            <string>ов</string>
            <key>other</key>
            <string>ов</string>
        </dict>
    </dict>
    <key>instructions</key>
    <dict>
        <key>NSStringLocalizedFormatKey</key>
        <string>Инструкци%#@VARIABLE@</string>
        <key>VARIABLE</key>
        <dict>
            <key>NSStringFormatSpecTypeKey</key>
            <string>NSStringPluralRuleType</string>
            <key>NSStringFormatValueTypeKey</key>
            <string>d</string>
            <key>zero</key>
            <string>й</string>
            <key>one</key>
            <string>я</string>
            <key>two</key>
            <string>и</string>
            <key>few</key>
            <string>и</string>
            <key>many</key>
            <string>й</string>
            <key>other</key>
            <string>и</string>
        </dict>
    </dict>
    <key>questions</key>
    <dict>
        <key>NSStringLocalizedFormatKey</key>
        <string>Вопрос%#@VARIABLE@</string>
        <key>VARIABLE</key>
        <dict>
            <key>NSStringFormatSpecTypeKey</key>
            <string>NSStringPluralRuleType</string>
            <key>NSStringFormatValueTypeKey</key>
            <string>d</string>
            <key>zero</key>
            <string>ов</string>
            <key>one</key>
            <string></string>
            <key>two</key>
            <string>а</string>
            <key>few</key>
            <string>а</string>
            <key>many</key>
            <string>ов</string>
            <key>other</key>
            <string>ов</string>
        </dict>
    </dict>
</dict>
</plist>
tomlokhorst commented 5 years ago

I copied your examples into Test.strings and Test.stringsdict files, and I'm not seeing any warnings.

mikhail-muzhev commented 5 years ago

Hm, that's really weird...

mikhail-muzhev commented 5 years ago

Shame on me... I've forgotten to click on localize button after .stringdict-file creation