Dimillian / IceCubesApp

A SwiftUI Mastodon client
https://apps.apple.com/us/app/ice-cubes-for-mastodon/id6444915884
GNU Affero General Public License v3.0
5.51k stars 538 forks source link

Bug: string not using localisation #816

Closed xabirequejo closed 1 year ago

xabirequejo commented 1 year ago

Environment:

Description

String account.detail.n-fields %lld doesn't seem to use localisation on 1.4.6. It shows the string itself, not the text. Same issue with account.detail.featured-tags-n-posts. The app shows the right text when the language is changed to British English or Catalan.

Related Issues

Very similar to #525: account.followers is not translated to Catalan

Illustration

IMG_3073

te6-in commented 1 year ago

I looked up the Localizable.strings file and it seems that the entire line is missing for both. Doesn't look like a typo issue to me.

Dimillian commented 1 year ago
image

You need to add it there.

xabirequejo commented 1 year ago

Hmmokay. I must've dropped them at some point; I'm sure they where showing the other day. I have added them back to where they were before, I believe. I'm going to take a look at plurals. Sorry and thanks.

xabirequejo commented 1 year ago

Hi again,

te6-in commented 1 year ago

Hope this helps!

xabirequejo commented 1 year ago

Thank you, I'm not sure how to use it, though. Would this be ok if the goal was to change the order to %2$lld people wrote %1$lld posts (instead of %lld posts from %lld people?

<key>design.tag.n-posts-from-n-participants %1$lld %2$lld</key>
    <dict>
        <key>NSStringLocalizedFormatKey</key>
        <string>%#@tagParticipantsCount@ %#@tagPostsCount@</string>
        <key>tagParticipantsCount</key>
        <dict>
                <key>NSStringFormatSpecTypeKey</key>
            <string>NSStringPluralRuleType</string>
            <key>NSStringFormatValueTypeKey</key>
            <string>lld</string>
            <key>one</key>
            <string>Partaide batek egindako</string>
            <key>other</key>
            <string>%2$lld partaidek egindako</string>
        </dict>
        <key>tagPostsCount</key>
        <dict>
            <key>NSStringFormatSpecTypeKey</key>
            <string>NSStringPluralRuleType</string>
            <key>NSStringFormatValueTypeKey</key>
            <string>lld</string>
            <key>one</key>
            <string>bidalketa %lld</string>
            <key>other</key>
            <string>%1$lld bidalketa</string>
        </dict>
    </dict>

Can I modify the main <key> or does that need to be as is? — And about the last two bullet points on the previous post, I was wondering about the source of the time/date that is shown on posts as it's not correct in Basque. I thought that maybe I could have a look at it. IMG_3094 IMG_3093

te6-in commented 1 year ago

@xabirequejo

The main key should remain the same. If you want to change the order, you should modify the NSStringLocalizedFormatKey value.

<dict>
    <key>design.tag.n-posts-from-n-participants %lld %lld</key>
    <dict>
        <key>NSStringLocalizedFormatKey</key>
        <string>%#@tagPostsCount@ written by %#@tagParticipantsCount@</string>
        <key>tagPostsCount</key>
        <dict>
            <key>NSStringFormatSpecTypeKey</key>
            <string>NSStringPluralRuleType</string>
            <key>NSStringFormatValueTypeKey</key>
            <string>lld</string>
            <key>one</key>
            <string>%lld post</string>
            <key>other</key>
            <string>%lld posts</string>
        </dict>
        <key>tagParticipantsCount</key>
        <dict>
            <key>NSStringFormatSpecTypeKey</key>
            <string>NSStringPluralRuleType</string>
            <key>NSStringFormatValueTypeKey</key>
            <string>lld</string>
            <key>one</key>
            <string>%lld person</string>
            <key>other</key>
            <string>%lld people</string>
        </dict>
    </dict>
</dict>
</plist>

Take a look at this line from the actual code and let's assume that tag.totalUses is 4 and tag.totalAccounts is 1. The stringsdict above should say 4 posts written by 1 person.

<dict>
    <key>design.tag.n-posts-from-n-participants %lld %lld</key>
    <dict>
        <key>NSStringLocalizedFormatKey</key>
        <string>%2$#@tagParticipantsCount@ wrote %1$#@tagPostsCount@</string>
        <key>tagPostsCount</key>
        <dict>
            <key>NSStringFormatSpecTypeKey</key>
            <string>NSStringPluralRuleType</string>
            <key>NSStringFormatValueTypeKey</key>
            <string>lld</string>
            <key>one</key>
            <string>%lld post</string>
            <key>other</key>
            <string>%lld posts</string>
        </dict>
        <key>tagParticipantsCount</key>
        <dict>
            <key>NSStringFormatSpecTypeKey</key>
            <string>NSStringPluralRuleType</string>
            <key>NSStringFormatValueTypeKey</key>
            <string>lld</string>
            <key>one</key>
            <string>%lld person</string>
            <key>other</key>
            <string>%lld people</string>
        </dict>
    </dict>
</dict>
</plist>

In the same situation, this stringsdict will say 1 person wrote 4 posts. The n$position specifier represents that it will grab the nth variable from the code.

In the case of the date & time formatting, I believe there's nothing we can do about it only with string localizations for now.

xabirequejo commented 1 year ago

Hey, @te6-in: Thank you very much for your help. Now Basque localisation makes a lot more sense with the new order. Thanks

te6-in commented 1 year ago

I'm glad it was helpful 😄 I learned a lot of new things too.