The key for a string in the table that table identifies.
options
オプション
Options that affect the handling of attributes.
属性の取り扱いに影響を及ぼすオプション。
table
The bundle’s string table to search. If table is nil or is an empty string, the method attempts to use the table in Localizable.strings. The default is nil.
bundle
The bundle to use for looking up strings. If nil, an app searches its main bundle. The default is nil.
省略時にはnilです。
locale
The locale of the localized string to retrieve. If nil, this initializer uses the current locale. The default is nil.
省略時にはnilです。
comment
The comment to place above the key-value pair in the strings file. This parameter provides the translator with some context about the localized string’s presentation to the user.
stringsファイルにおいてキー値ペアの上方に置くことになるコメント。このパラメータは、ローカライズされた文字列のユーザへの提示についての何らかの文脈をトランスレータに提供します。
scope
An AttributeScopes key path that identifies an attribute scope to associate with the attributed string.
Discussion
議論
To create localizable attributed strings, use Markdown syntax in your strings files. The following example shows a string from a Spanish localization:
You load this string with one of the initializers that takes localized as its first parameter, like the following:
The resulting attributed string contains an inlinePresentationIntent attribute to apply the emphasized presentation intent over the entire string. It also applies the link attribute to the text sitio web. User interface frameworks like SwiftUI and UIKit can then use these attributes when presenting the text to the user.
Applying Automatic Grammar Agreement
To apply the automatic grammar agreement feature when loading a localized string, use Apple’s Markdown extension syntax: ^[text to inflect](inflect: true). The following example shows a format string with a Spanish localization for a food-ordering app.
You load and localize this string as follows:
When the string loads, the automatic grammar agreement feature adjusts the text for foodSizeSelection and food to match the number and gender of the sentence.
See Also
参照
Creating a Localized Attributed String
ローカライズされた属性付き文字列を作成する