text
stringlengths
1
372
wrapped with a pair of single quotes.
to use a normal single quote character,
use a pair of consecutive single quotes.
for example, the follow text is converted
to a dart string:
the resulting string is as follows:
<topic_end>
<topic_start>
messages with numbers and currencies
numbers, including those that represent currency values,
are displayed very differently in different locales.
the localizations generation tool in
flutter_localizations uses the
NumberFormat
class in the intl package to format
numbers based on the locale and the desired format.
the int, double, and number types can use any of the
following NumberFormat constructors:
the starred NumberFormat constructors in the table
offer optional, named parameters.
those parameters can be specified as the value
of the placeholder’s optionalParameters object.
for example, to specify the optional decimalDigits
parameter for compactCurrency,
make the following changes to the lib/l10n/app_en.arg file:
<code_start>
"numberofdatapoints": "number of data points: {value}",
"@numberofdatapoints": {
"description": "a message with a formatted int parameter",
"placeholders": {
"value": {
"type": "int",
"format": "compactcurrency",
"optionalparameters": {
"decimaldigits": 2
}
}
}
}
<code_end>
<topic_end>
<topic_start>
messages with dates
dates strings are formatted in many different ways
depending both the locale and the app’s needs.
placeholder values with type DateTime are formatted with
DateFormat in the intl package.
there are 41 format variations,
identified by the names of their DateFormat factory constructors.
in the following example, the DateTime value
that appears in the helloWorldOn message is
formatted with DateFormat.yMd:
in an app where the locale is US english,
the following expression would produce “7/9/1959”.
in a russian locale, it would produce “9.07.1959”.
<topic_end>
<topic_start>
localizing for iOS: updating the iOS app bundle
typically, iOS applications define key application metadata,
including supported locales, in an info.plist file
that is built into the application bundle.
to configure the locales supported by your app,
use the following instructions:
open your project’s ios/Runner.xcworkspace xcode file.
in the project navigator, open the info.plist file
under the runner project’s runner folder.
select the information property list item.
then select add item from the editor menu,
and select localizations from the pop-up menu.
select and expand the newly-created localizations item.
for each locale your application supports,
add a new item and select the locale you wish to add
from the pop-up menu in the value field.
this list should be consistent with the languages listed
in the supportedLocales parameter.
once all supported locales have been added, save the file.
<topic_end>
<topic_start>
advanced topics for further customization
this section covers additional ways to customize a
localized flutter application.
<topic_end>
<topic_start>
advanced locale definition
some languages with multiple variants require more than just a
language code to properly differentiate.
for example, fully differentiating all variants of
chinese requires specifying the language code, script code,
and country code. this is due to the existence
of simplified and traditional script, as well as regional
differences in the way characters are written within the same script type.
in order to fully express every variant of chinese for the
country codes CN, TW, and HK, the list of supported
locales should include:
<code_start>
supportedLocales: [
Locale.fromSubtags(languageCode: 'zh'), // generic chinese 'zh'
Locale.fromSubtags(
languageCode: 'zh',
scriptCode: 'hans'), // generic simplified chinese 'zh_hans'