Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

String Constant as a Localized String

I would like to localize my constants. Constants are defined and declared the usual way:

extern NSString * const kStringName;

NSString * const kStringName = @"Whatever...";

How to make it localizable? This just can not work...

NString * const kStringName = NSLocalizedString(@"Whatever...", @"Whatever...");

Thank you!

like image 272
user500 Avatar asked Apr 07 '11 13:04

user500


People also ask

What does localized string mean?

There are two categories of localized strings: the strings included in the installation package's UI, common to every MSI file. the strings included in your project, that are particular to the current project: the name of your application, file names, registry values, properties etc.

Can a constant Be a string?

A string constant is an arbitrary sequence of characters that are enclosed in single quotation marks (' '). For example, 'This is a string'. You can embed single quotation marks in strings by typing two adjacent single quotation marks.

What is localized string key?

The key used to look up an entry in a strings file or strings dictionary file. iOS 13.0+ iPadOS 13.0+ macOS 10.15+ Mac Catalyst 13.0+ tvOS 13.0+ watchOS 6.0+

How do you represent a string constant?

Answer. Explanation: A string constant consists of zero or more characters enclosed by apostrophes ( ' ) or quotes ( " ). ... This is because a quote character followed by a digit from 0 to 7 represents an octal numeric constant, not a string, and the character 9 is an illegal octal digit.


1 Answers

A const variable may already optimized at compile time so you can't change it at runtime. You simply can't have const localized strings.

like image 197
Bastian Avatar answered Sep 27 '22 22:09

Bastian