Some iOS controls have localised strings built in by Apple. The "Done", "Edit", "Back" bar button items are some examples. Is there a way to access these strings?
I am making a UIActionSheet with standard "Delete" or "Cancel" options, just like when you delete a contact in the Contacts app.
Is there a way to reference these strings in code? If not, is there somewhere I can at least get these strings (like extracting them from the resources of an Apple app)? It would save extra localisation work and would ensure consistency with the platform.
The key used to look up an entry in a strings file or strings dictionary file.
NSLocalizedString is a Foundation macro that returns a localized version of a string. It has two arguments: key , which uniquely identifies the string to be localized, and comment , a string that is used to provide sufficient context for accurate translation.
If iOS is like Mac OS each app carries their own Localizable.strings file. And in each strings file you have all those little strings like Done, Edit, Cancel and so on.
These are some strings I copied from the English Localizable.string file from Finder.app:
<key>AL1</key>
<string>Cancel</string>
<key>AL4</key>
<string>OK</string>
<key>AL9</key>
<string>Don’t Save</string>
<key>FF24</key>
<string>Save</string>
<key>U32</key>
<string>Yes</string>
<key>U33</key>
<string>No</string>
You get the idea. Each little string is localized in each app.
This one is from iTunes.app.
/* ===== Ask User Strings ===== */
"23987.001" = "Yes";
"23987.002" = "No";
"23987.003" = "OK";
"23987.004" = "Cancel";
"23987.005" = "Ignore";
"23987.006" = "Quit";
"23987.007" = "Don’t Quit";
"23987.008" = "Apply";
"23987.009" = "Don’t Apply";
"23987.010" = "Later";
"23987.011" = "Don’t Save";
"23987.012" = "Save";
"23987.013" = "Stop";
"23987.014" = "Continue";
"23987.015" = "Delete";
"23987.016" = "Remove";
"23987.017" = "Replace";
"23987.018" = "Don’t Replace";
"23987.019" = "Do not ask me again";
Looks a little bit more structured. Copying their files is probably not allowed though ;-)
An answer in apples devforum by Quinn (eskimo1) from Apple Developer Relations.
Some UI elements are automatically localised for you. For example, the artwork on a UIBarButtonItem. However, there's no supported way to get to the strings like "OK" and "Cancel" as they are used in a UIActionSheet. They should, however, be trivial for your localiser to cope with.
2 years old though. But newer threads have the same outcome. No way to get those strings.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With