10

The Apple docs for this (both in Xcode and webpage) have exactly no explanation of the parameters.

https://developer.apple.com/documentation/foundation/1418095-nslocalizedstring

For reference, the function signature is

NSLocalizedString(
    _ key    : String, 
    tableName: String? = default,  // ??
    bundle   : Bundle = default, 
    value    : String = default,   // ????
    comment  : String
) -> String

I have a vague idea what the tableName is -- but more information would be helpful. (Is it merely the filename for a strings file?) I have no idea what value is for.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Andrew Duncan
  • 3,553
  • 4
  • 28
  • 55
  • Please read the documentation of [`Bundle`'s localizedString](https://developer.apple.com/documentation/foundation/bundle/1417694-localizedstring) – vadian Nov 10 '17 at 16:34

1 Answers1

14

The Objective-C documentation for NSLocalizedStringWithDefaultValue explains the parameters:

Parameters

key
The key for a string in the specified table.

tableName
The name of the table containing the key-value pairs. Also, the suffix for the strings file (a file with the .strings extension) to store the localized string.

bundle
The bundle containing the strings file.

value
The value to return if key is nil or if a localized string for key can’t be found in the table.

comment
The comment to place above the key-value pair in the strings file.

Basically, the key is looked up in a file named tableName.strings in the specified bundle. That strings file will have the format:

# comment
"key" = "value"
Community
  • 1
  • 1
rmaddy
  • 314,917
  • 42
  • 532
  • 579
  • Yep, just found it too. Thanks. Though one would think the actual underlying function would be documented. Now I just have to worry about word-order, plurals, placeholders, etc. We're doing Arabic and Mandarin... – Andrew Duncan Nov 10 '17 at 17:14