[Gallery] Localize durations for Crane (#294)

* Correctly formatted placeholders in intl_en_US.arb

* Add flight duration strings

* Replace duration formatter with localized string
pull/298/head
Per Classon 5 years ago committed by GitHub
parent 36e5f9fed5
commit 5d007aeb86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

File diff suppressed because it is too large Load Diff

@ -57,14 +57,18 @@
"@cardsDemoExploreSemantics": {
"description": "Semantics label for Explore. Label tells user to explore the destinationName to the user. Example Explore Tamil",
"placeholders": {
"destinationName": "Tamil"
"destinationName": {
"example": "Tamil"
}
}
},
"cardsDemoShareSemantics": "Share {destinationName}",
"@cardsDemoShareSemantics": {
"description": "Semantics label for Share. Label tells user to share the destinationName to the user. Example Share Tamil",
"placeholders": {
"destinationName": "Tamil"
"destinationName": {
"example": "Tamil"
}
}
},
"cardsDemoTravelDestinationTitle1": "Top 10 Cities to Visit in Tamil Nadu",
@ -307,35 +311,45 @@
"@rallyAlertsMessageHeadsUpShopping": {
"description": "Alert message shown when for example, user has used more than 90% of their shopping budget.",
"placeholders": {
"percent": "90%"
"percent": {
"example": "90%"
}
}
},
"rallyAlertsMessageSpentOnRestaurants": "Youve spent {amount} on Restaurants this week.",
"@rallyAlertsMessageSpentOnRestaurants": {
"description": "Alert message shown when for example, user has spent $120 on Restaurants this week.",
"placeholders": {
"amount": "$120"
"amount": {
"example": "$120"
}
}
},
"rallyAlertsMessageATMFees": "Youve spent {amount} in ATM fees this month",
"@rallyAlertsMessageATMFees": {
"description": "Alert message shown when for example, the user has spent $24 in ATM fees this month.",
"placeholders": {
"amount": "24"
"amount": {
"example": "24"
}
}
},
"rallyAlertsMessageCheckingAccount": "Good work! Your checking account is {percent} higher than last month.",
"@rallyAlertsMessageCheckingAccount": {
"description": "Alert message shown when for example, the checking account is 1% higher than last month.",
"placeholders": {
"percent": "1%"
"percent": {
"example": "1%"
}
}
},
"rallyAlertsMessageUnassignedTransactions": "{count, plural, =1{Increase your potential tax deduction! Assign categories to 1 unassigned transaction.}other{Increase your potential tax deduction! Assign categories to {count} unassigned transactions.}}",
"@rallyAlertsMessageUnassignedTransactions": {
"description": "Alert message shown when you have unassigned transactions.",
"placeholders": {
"count": "2"
"count": {
"example": "2"
}
}
},
"rallySeeAllAccounts": "See all accounts",
@ -354,28 +368,48 @@
"@rallyAccountAmount": {
"description": "Semantics label for row with bank account name (for example checking) and its bank account number (for example 123), with how much money is deposited in it (for example $12).",
"placeholders": {
"accountName": "Home Savings",
"accountNumber": "1234",
"amount": "$12"
"accountName": {
"example": "Home Savings"
},
"accountNumber": {
"example": "1234"
},
"amount": {
"example": "$12"
}
}
},
"rallyBillAmount": "{billName} bill due {date} for {amount}.",
"@rallyBillAmount": {
"description": "Semantics label for row with a bill (example name is rent), when the bill is due (1/12/2019 for example) and for how much money ($12).",
"placeholders": {
"billName": "Rent",
"date": "1/24/2019",
"amount": "$12"
"billName": {
"example": "Rent"
},
"date": {
"example": "1/24/2019"
},
"amount": {
"example": "$12"
}
}
},
"rallyBudgetAmount": "{budgetName} budget with {amountUsed} used of {amountTotal}, {amountLeft} left",
"@rallyBudgetAmount": {
"description": "Semantics label for row with a budget (housing budget for example), with how much is used of the budget (for example $5), the total budget (for example $100) and the amount left in the budget (for example $95).",
"placeholders": {
"budgetName": "Groceries",
"amountUsed": "$5",
"amountTotal": "$100",
"amountLeft": "$95"
"budgetName": {
"example": "Groceries"
},
"amountUsed": {
"example": "$5"
},
"amountTotal": {
"example": "$100"
},
"amountLeft": {
"example": "$95"
}
}
},
"craneDescription": "A personalized travel app",
@ -2318,6 +2352,36 @@
"@craneFormDates": {
"description": "Form field label to select multiple dates."
},
"craneHours": "{hours, plural, =1{1h} other{{hours}h}}",
"@craneHours": {
"description": "Generic text for an amount of hours, abbreviated to the shortest form. For example 1h. {hours} should remain untranslated.",
"placeholders": {
"hours": {
"example": "1"
}
}
},
"craneMinutes": "{minutes, plural, =1{1m} other{{minutes}m}}",
"@craneMinutes": {
"description": "Generic text for an amount of minutes, abbreviated to the shortest form. For example 15m. {minutes} should remain untranslated.",
"placeholders": {
"minutes": {
"example": "15"
}
}
},
"craneFlightDuration": "{hoursShortForm} {minutesShortForm}",
"@craneFlightDuration": {
"description": "A pattern to define the layout of a flight duration string. For example in English one might say 1h 15m. Translation should only rearrange the inputs. {hoursShortForm} would for example be replaced by 1h, already translated to the given locale. {minutesShortForm} would for example be replaced by 15m, already translated to the given locale.",
"placeholders": {
"hoursShortForm": {
"example": "1h"
},
"minutesShortForm": {
"example": "15m"
}
}
},
"craneFly": "FLY",
"@craneFly": {
"description": "Title for FLY tab."
@ -2347,7 +2411,7 @@
"description": "Label indicating if a flight is nonstop or how many layovers it includes.",
"placeholders": {
"numberOfStops": {
"example": 2
"example": "2"
}
}
},

@ -2189,6 +2189,18 @@
name="craneFormDates"
description="Form field label to select multiple dates."
>Select Dates</string>
<string
name="craneHours"
description="Generic text for an amount of hours, abbreviated to the shortest form. For example 1h. {hours} should remain untranslated."
>{hours, plural, =1{1h} other{{hours}h}}</string>
<string
name="craneMinutes"
description="Generic text for an amount of minutes, abbreviated to the shortest form. For example 15m. {minutes} should remain untranslated."
>{minutes, plural, =1{1m} other{{minutes}m}}</string>
<string
name="craneFlightDuration"
description="A pattern to define the layout of a flight duration string. For example in English one might say 1h 15m. Translation should only rearrange the inputs. {hoursShortForm} would for example be replaced by 1h, already translated to the given locale. {minutesShortForm} would for example be replaced by 15m, already translated to the given locale."
>{hoursShortForm} {minutesShortForm}</string>
<string
name="craneFly"
description="Title for FLY tab."

@ -31,15 +31,23 @@ class MessageLookup extends MessageLookupByLibrary {
static m2(totalRestaurants) =>
"${Intl.plural(totalRestaurants, zero: 'No Restaurants', one: '1 Restaurant', other: '${totalRestaurants} Restaurants')}";
static m29(hoursShortForm, minutesShortForm) =>
"${hoursShortForm} ${minutesShortForm}";
static m3(numberOfStops) =>
"${Intl.plural(numberOfStops, zero: 'Nonstop', one: '1 stop', other: '${numberOfStops} stops')}";
static m30(hours) => "${Intl.plural(hours, one: '1h', other: '${hours}h')}";
static m31(minutes) =>
"${Intl.plural(minutes, one: '1m', other: '${minutes}m')}";
static m4(totalProperties) =>
"${Intl.plural(totalProperties, zero: 'No Available Properties', one: '1 Available Properties', other: '${totalProperties} Available Properties')}";
static m29(value) => "${value} with honey";
static m32(value) => "${value} with honey";
static m30(value) => "${value} with sugar";
static m33(value) => "${value} with sugar";
static m5(value) => "Item ${value}";
@ -231,6 +239,7 @@ class MessageLookup extends MessageLookupByLibrary {
"craneEatRestaurants": m2,
"craneEatSubhead": MessageLookupByLibrary.simpleMessage(
"Explore Restaurants by Destination"),
"craneFlightDuration": m29,
"craneFly": MessageLookupByLibrary.simpleMessage("FLY"),
"craneFly0":
MessageLookupByLibrary.simpleMessage("Aspen, United States"),
@ -295,6 +304,8 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("Choose Origin"),
"craneFormTime": MessageLookupByLibrary.simpleMessage("Select Time"),
"craneFormTravelers": MessageLookupByLibrary.simpleMessage("Travelers"),
"craneHours": m30,
"craneMinutes": m31,
"craneSleep": MessageLookupByLibrary.simpleMessage("SLEEP"),
"craneSleep0": MessageLookupByLibrary.simpleMessage("Malé, Maldives"),
"craneSleep0SemanticLabel":
@ -403,8 +414,8 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("Jelly bean"),
"dataTableRowLollipop":
MessageLookupByLibrary.simpleMessage("Lollipop"),
"dataTableRowWithHoney": m29,
"dataTableRowWithSugar": m30,
"dataTableRowWithHoney": m32,
"dataTableRowWithSugar": m33,
"demo2dTransformationsDescription": MessageLookupByLibrary.simpleMessage(
"Tap to edit tiles, and use gestures to move around the scene. Drag to pan, pinch to zoom, rotate with two fingers. Press the reset button to return to the starting orientation."),
"demo2dTransformationsEditTooltip":

@ -2,17 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:duration/duration.dart';
import 'package:flutter/material.dart';
import 'package:gallery/l10n/gallery_localizations.dart';
// Duration of time (e.g. 16h 12m)
String formattedDuration(BuildContext context, Duration duration,
{bool abbreviated}) {
return prettyDuration(
duration,
spacer: '',
delimiter: ' ',
abbreviated: abbreviated,
tersity: DurationTersity.minute,
);
final hoursShortForm =
GalleryLocalizations.of(context).craneHours(duration.inHours.toInt());
final minutesShortForm =
GalleryLocalizations.of(context).craneMinutes(duration.inMinutes % 60);
return GalleryLocalizations.of(context)
.craneFlightDuration(hoursShortForm, minutesShortForm);
}

@ -99,13 +99,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.3"
duration:
dependency: "direct main"
description:
name: duration
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.8"
flare_dart:
dependency: transitive
description:

@ -14,7 +14,6 @@ dependencies:
intl:
intl_translation:
flutter_localized_locales:
duration:
cupertino_icons: ^0.1.2
rally_assets: 1.0.0
meta:

Loading…
Cancel
Save