Home Programming Localisation in Xcode 15. Utilise new String Catalogs to… | by Jacob Bartlett | Nov, 2023

Localisation in Xcode 15. Utilise new String Catalogs to… | by Jacob Bartlett | Nov, 2023

0
Localisation in Xcode 15. Utilise new String Catalogs to… | by Jacob Bartlett | Nov, 2023

[ad_1]

Utilise new String Catalogs to internationalize your Swift apps

Photograph by Kyle Glenn on Unsplash

String Catalogs are a neat new function launched in WWDC 2023.

.strings information (and, to a good better extent, .stringsdict information) had been one of many last bastions of Goal-C-era cruft within the Apple improvement atmosphere.

However no extra.

I’ve been upgrading Bev, my trusty, boozy aspect mission, to iOS 17. Alongside the way in which, I’ve been implementing the teachings from WWDC23’s Uncover String Catalogs.

Be part of me on the journey!

Previous to Xcode 15, most of your strings can be outlined in a .strings file:

// House display screen
"home_screen_title"="House";
"home_screen_button_add_friend"="Add buddy";
"home_screen_button_settings"="Settings";
"home_screen_friends_list"="Your folks listing";

You missed one semicolon?

Too dangerous, each string in your module is now damaged, displaying home_screen_title or home_screen_button_add_friend rather than your precise copy.

.stringsdict information are even harder to understand. As a result of totally different languages have totally different grammatical guidelines for dealing with pluralisation, we want a much more advanced beast to outline a single string, even to say one thing so simple as “3 pals”:

<dict>
<key>home_screen_friends_count</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>%#@friends_count@</string>
<key>friends_count</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>NSStringFormatValueTypeKey</key>
<string>d</string>
<key>zero</key>
<string>No pals</string>
<key>one</key>
<string>1 buddy</string>
<key>different</key>
<string>%d pals</string>
</dict>
</dict>
</dict>

Once I first wrote Bev, I did not hassle internationalising the strings.

😱

[ad_2]

Supply hyperlink

LEAVE A REPLY

Please enter your comment!
Please enter your name here