Skip to content

Commit

Permalink
Internationalization and Localization - Part 1 (#171)
Browse files Browse the repository at this point in the history
* Update main.dart
* Include intl package
* Generate keys arb file

---------

Co-authored-by: René Apitzsch <[email protected]>
Co-authored-by: Robin Thomas <[email protected]>
  • Loading branch information
3 people authored Jun 6, 2023
1 parent 6dd8612 commit 857d378
Show file tree
Hide file tree
Showing 6 changed files with 362 additions and 7 deletions.
3 changes: 3 additions & 0 deletions l10n.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
arb-dir: lib/l10n
template-arb-file: app_en.arb
output-localization-file: app_localizations.dart
141 changes: 141 additions & 0 deletions lib/l10n/app_de.arb
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
{
"@@locale": "de",
"aboutTitle": "Über",
"@aboutTitle": {},
"aboutSlogan": "Nächster Halt: Barrierefreiheit",
"@aboutSlogan": {},
"aboutVersion": "Version",
"@aboutVersion": {},
"aboutAuthorsLabel": "Autoren",
"@aboutAuthorsLabel": {},
"aboutAuthorsDescription": "{appName} Mitwirkende",
"@aboutAuthorsDescription": {},
"aboutPrivacyPolicyLabel": "Datenschutzerklärung",
"@aboutPrivacyPolicyLabel": {},
"aboutIdeaLabel": "Idee",
"@aboutIdeaLabel": {},
"aboutIdeaDescription": "Technische Universität Chemnitz\nProfessur Schaltkreis- und Systementwurf",
"@aboutIdeaDescription": {},
"aboutLicenseLabel": "Lizenz",
"@aboutLicenseLabel": {},
"aboutLicensePackageLabel": "Lizenzen verwendeter Pakete",
"@aboutLicensePackageLabel": {},
"aboutSourceCodeLabel": "Quellcode",
"@aboutSourceCodeLabel": {},

"helpTitle": "Hilfe",
"@helpTitle": {},
"helpOnboardingLabel": "Einführung erneut anschauen",
"@helpOnboardingLabel": {},
"helpReportError": "Fehler melden",
"@helpReportError": {},

"onboardingGreetingTitle": "Hey!",
"@onboardingGreetingTitle": {},
"onboardingGreetingDescription": "Wir freuen uns, dass du hier bist und deinen Teil zu einem besseren Nahverkehr beitragen willst.",
"@onboardingGreetingDescription": {},
"onboardingGreetingButton": "So funktioniert's",
"@onboardingGreetingButton": {},

"onboardingSurveyTitle": "Schau's dir an",
"@onboardingSurveyTitle": {},
"onboardingSurveyDescription": "Begib dich zu einer Haltestelle in deiner Umgebung, um ihren aktuellen Zustand zu erfassen.",
"@onboardingSurveyDescription": {},
"onboardingSurveyingButton": "Mach' ich",
"@onboardingSurveyingButton": {},

"onboardingAnsweringTitle": "Jetzt bist du gefragt",
"@onboardingAnsweringTitle": {},
"onboardingAnsweringDescription": "Wähle zur Erfassung einen Marker in der App aus und beantworte die angezeigten Fragen.",
"@onboardingAnsweringDescription": {},
"onboardingAnsweringButton": "Okay, verstanden",
"@onboardingAnsweringButton": {},

"onboardingContributingTitle": "Sharing is caring",
"@onboardingContributingTitle": {},
"onboardingContributingDescription": "Lade deine Antworten auf OpenStreetMap hoch und stelle sie so der ganzen Welt zur Verfügung.",
"@onboardingContributingDescription": {},
"onboardingContributingButton": "Los geht's",
"@onboardingContributingButton": {},

"privacyPolicyTitle": "Datenschutzerklärung",
"@privacyPolicyTitle": {},

"settingsTitle": "Einstellungen",
"@settingsTitle": {},
"settingsProfessionalQuestionsLabel": "Profi-Fragen anzeigen",
"@settingsProfessionalQuestionsLabel": {},
"settingsProfessionalQuestionsDescription": "Aus Sicherheitsgründen nur für Fachpersonal bestimmt",
"@settingsProfessionalQuestionsDescription": {},
"settingsThemeLabel": "Farbliche Darstellung der App",
"@settingsThemeLabel": {},
"settingsThemeDialogTitle": "Design auswählen",
"@settingsThemeDialogTitle": {},
"settingsThemeOptionSystem": "Systemeinstellung",
"@settingsThemeOptionSystem": {},
"settingsThemeOptionLight": "Hell",
"@settingsThemeOptionLight": {},
"settingsThemeOptionDark": "Dunkel",
"@settingsThemeOptionDark": {},

"logoutDialogTitle": "Von OSM abmelden?",
"@logoutDialogTitle": {},
"logoutDialogDescription": "Wenn du dich abmeldest, kannst du keine Änderungen mehr zu OpenStreetMap hochladen.",
"@logoutDialogDescription": {},
"loginHint": "Melde dich mit deinem OpenStreetMap-Konto an, um deine Änderungen hochzuladen.",
"@loginHint": {},

"numberInputPlaceholder": "Hier eintragen...",
"@numberInputPlaceholder": {},
"numberInputFallbackName": "Wert",
"@numberInputFallbackName": {},
"numberInputValidationError": "Ungültige Zahl",
"@numberInputValidationError": {},
"numberInputValidationErrorMax": "{nameString} muss kleiner sein als {max}.",
"@numberInputValidationErrorMax": {},
"numberInputValidationErrorMin": "{nameString} muss größer sein als {min}.",
"@numberInputValidationErrorMin": {},

"stringInputPlaceholder": "Hier eintragen...",
"@stringInputPlaceholder": {},
"stringInputValidationErrorMin": "Eingabe zu kurz",
"@stringInputValidationErrorMin": {},

"changesetCommentMessage": "Details zu {mapFeaturesString} im Haltestellenbereich {stopsString} hinzugefügt.",
"@changesetCommentMessage": {},
"changesetCommentConjunctionString": "und",
"@changesetCommentConjunctionString": {},
"uploadMessageSuccess": "Änderungen erfolgreich übertragen.",
"@uploadMessageSuccess": {},
"uploadMessageServerConnectionError": "Fehler: Keine Verbindung zum OSM-Server.",
"@uploadMessageServerConnectionError": {},
"uploadMessageUnknownConnectionError": "Unbekannter Fehler bei der Übertragung.",
"@uploadMessageUnknownConnectionError": {},
"questionnaireSummaryMessage": "Danke {userName} für deine Antworten.\nBitte prüfe sie vor dem Hochladen nochmal.",
"@questionnaireSummaryMessage": {},

"back": "Zurück",
"@back": {},
"next": "Weiter",
"@next": {},
"cancel": "Abbrechen",
"@cancel": {},
"confirm": "Bestätigen",
"@confirm": {},
"finish": "Abschließen",
"@finish": {},
"login": "Anmelden",
"@login": {},
"logout": "Abmelden",
"@logout": {},
"skip": "Überspringen",
"@skip": {},
"days": "{day, plural, =0 {Tage} =1 {Tag} other {Tage}}",
"@days": {},
"hours": "{hour, plural, =0 {Stunden} =1 {Stunde} other {Stunden}}",
"@hours": {},
"minutes": "{minute, plural, =0 {Minuten} =1 {Minute} other {Minuten}}",
"@minutes": {},
"seconds": "{second, plural, =0 {Sekunden} =1 {Sekunde} other {Sekunden}}",
"@seconds": {}
}
211 changes: 211 additions & 0 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
{
"@@locale": "en",
"aboutTitle": "About",
"@aboutTitle": {},
"aboutSlogan": "Next stop: Accessibility",
"@aboutSlogan": {},
"aboutVersion": "Version",
"@aboutVersion": {},
"aboutAuthorsLabel": "Authors",
"@aboutAuthorsLabel": {},
"aboutAuthorsDescription": "{appName} contributors",
"@aboutAuthorsDescription": {
"placeholders": {
"appName": {
"type": "String"
}
}
},
"aboutPrivacyPolicyLabel": "Privacy Policy",
"@aboutPrivacyPolicyLabel": {},
"aboutIdeaLabel": "Idea",
"@aboutIdeaLabel": {},
"aboutIdeaDescription": "Chemnitz University of Technology\nProfessorship Circuit and System Design",
"@aboutIdeaDescription": {},
"aboutLicenseLabel": "License",
"@aboutLicenseLabel": {},
"aboutLicensePackageLabel": "Licenses of used packages",
"@aboutLicensePackageLabel": {},
"aboutSourceCodeLabel": "Source code",
"@aboutSourceCodeLabel": {},

"helpTitle": "Help",
"@helpTitle": {},
"helpOnboardingLabel": "Watch the introduction again",
"@helpOnboardingLabel": {},
"helpReportError": "Report an error",
"@helpReportError": {},

"onboardingGreetingTitle": "Hey!",
"@onboardingGreetingTitle": {},
"onboardingGreetingDescription": "We're glad you're here and want to do your part to improve public transport.",
"@onboardingGreetingDescription": {},
"onboardingGreetingButton": "Here's how it works",
"@onboardingGreetingButton": {},

"onboardingSurveyTitle": "Take a look",
"@onboardingSurveyTitle": {},
"onboardingSurveyDescription": "Go to a nearby stop to survey its current state.",
"@onboardingSurveyDescription": {},
"onboardingSurveyingButton": "I'll do it",
"@onboardingSurveyingButton": {},

"onboardingAnsweringTitle": "Now it's your turn",
"@onboardingAnsweringTitle": {},
"onboardingAnsweringDescription": "In order to collect data select a marker in the app and answer the displayed questions.",
"@onboardingAnsweringDescription": {},
"onboardingAnsweringButton": "Okay, got it",
"@onboardingAnsweringButton": {},

"onboardingContributingTitle": "Sharing is caring",
"@onboardingContributingTitle": {},
"onboardingContributingDescription": "Upload your answers to OpenStreetMap to share them with the whole world.",
"@onboardingContributingDescription": {},
"onboardingContributingButton": "Here we go",
"@onboardingContributingButton": {},

"privacyPolicyTitle": "Privacy Policy",
"@privacyPolicyTitle": {},

"settingsTitle": "Settings",
"@settingsTitle": {},
"settingsProfessionalQuestionsLabel": "Display Professional Questions",
"@settingsProfessionalQuestionsLabel": {},
"settingsProfessionalQuestionsDescription": "For safety reasons only intended for professionals",
"@settingsProfessionalQuestionsDescription": {},
"settingsThemeLabel": "Color Scheme of the App",
"@settingsThemeLabel": {},
"settingsThemeDialogTitle": "Select theme",
"@settingsThemeDialogTitle": {},
"settingsThemeOptionSystem": "System Setting",
"@settingsThemeOptionSystem": {},
"settingsThemeOptionLight": "Light",
"@settingsThemeOptionLight": {},
"settingsThemeOptionDark": "Dark",
"@settingsThemeOptionDark": {},

"logoutDialogTitle": "Log out of OSM?",
"@logoutDialogTitle": {},
"logoutDialogDescription": "If you log out, you can no longer upload changes to OpenStreetMap.",
"@logoutDialogDescription": {},
"loginHint": "Log in with your OpenStreetMap account to upload your changes.",
"@loginHint": {},

"numberInputPlaceholder": "Enter here...",
"@numberInputPlaceholder": {},
"numberInputFallbackName": "Value",
"@numberInputFallbackName": {
"description": "Fallback value for nameString in numberInputValidationErrorMax"
},
"numberInputValidationError": "Invalid number",
"@numberInputValidationError": {},
"numberInputValidationErrorMax": "{nameString} must be less than {max}.",
"@numberInputValidationErrorMax": {
"placeholders": {
"nameString": {
"type": "String"
},
"max": {
"type": "num",
"format": "compact"
}
}
},
"numberInputValidationErrorMin": "{nameString} must be greater than {min}.",
"@numberInputValidationErrorMin": {
"placeholders": {
"nameString": {
"type": "String"
},
"min": {
"type": "num",
"format": "compact"
}
}
},

"stringInputPlaceholder": "Enter here...",
"@stringInputPlaceholder": {},
"stringInputValidationErrorMin": "Input too short",
"@stringInputValidationErrorMin": {},

"changesetCommentMessage": "Added details to {mapFeaturesString} in stop area {stopsString}.",
"@changesetCommentMessage": {
"placeholders": {
"mapFeaturesString": {
"type": "String"
},
"stopsString": {
"type": "String"
}
}
},
"changesetCommentConjunctionString": "and",
"@changesetCommentConjunctionString": {},
"uploadMessageSuccess": "Changes successfully uploaded.",
"@uploadMessageSuccess": {},
"uploadMessageServerConnectionError": "Error: No connection to the OSM server.",
"@uploadMessageServerConnectionError": {},
"uploadMessageUnknownConnectionError": "Unknown error during transmission.",
"@uploadMessageUnknownConnectionError": {},
"questionnaireSummaryMessage": "Thank you {userName} for your answers.\nPlease verify them before uploading.",
"@questionnaireSummaryMessage": {
"placeholders": {
"userName": {
"type": "String"
}
}
},
"back": "Back",
"@back": {},
"next": "Next",
"@next": {},
"cancel": "Cancel",
"@cancel": {},
"confirm": "Confirm",
"@confirm": {},
"finish": "Finish",
"@finish": {},
"login": "Log in",
"@login": {},
"logout": "Log out",
"@logout": {},
"skip": "Skip",
"@skip": {},
"days": "{day, plural, =0 {Days} =1 {Day} other {Days}}",
"@days": {
"placeholders": {
"day": {
"type": "num",
"format": "compact"
}
}
},
"hours": "{hour, plural, =0 {Hours} =1 {Hour} other {Hours}}",
"@hours": {
"placeholders": {
"hour": {
"type": "num",
"format": "compact"
}
}
},
"minutes": "{minute, plural, =0 {Minutes} =1 {Minute} other {Minutes}}",
"@minutes": {
"placeholders": {
"minute": {
"type": "num",
"format": "compact"
}
}
},
"seconds": "{second, plural, =0 {Seconds} =1 {Second} other {Seconds}}",
"@seconds": {
"placeholders": {
"second": {
"type": "num",
"format": "compact"
}
}
}
}
8 changes: 3 additions & 5 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:provider/provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

import '/commons/themes.dart';
import '/commons/app_config.dart' as app_config;
Expand Down Expand Up @@ -47,10 +47,8 @@ class MyApp extends StatelessWidget {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: app_config.appName,
localizationsDelegates: GlobalMaterialLocalizations.delegates,
supportedLocales: const [
Locale('de','DE')
],
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
// used instead of home: because otherwise no pop page transition to the first screen will be applied
onGenerateRoute: (settings) => hasSeenOnboarding ? Routes.home : Routes.onboarding,
theme: lightTheme,
Expand Down
4 changes: 2 additions & 2 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ packages:
source: hosted
version: "4.0.15"
intl:
dependency: transitive
dependency: "direct main"
description:
name: intl
sha256: "910f85bce16fb5c6f614e117efa303e85a1731bb0081edf3604a2ae6e9a3cc91"
Expand Down Expand Up @@ -1191,4 +1191,4 @@ packages:
version: "3.1.1"
sdks:
dart: ">=2.19.0 <3.0.0"
flutter: ">=3.7.9"
flutter: ">=3.7.11"
Loading

0 comments on commit 857d378

Please sign in to comment.