Skip to content

Commit

Permalink
Add Turkish localization (#23)
Browse files Browse the repository at this point in the history
* feat: add turkish .arb file and generate strings

* refactor: improve handling of hardcoded localizations

* refactor: remove useless usePathUrlStrategy

* docs: add Turkish to supported languages

* docs: add credits for localizations and contributing section to README

* fix: wrong locale in locale check for hardcoded strings

* style: remove prints

* docs: add localization section to new CONTRIBUTING.md

* feat: add missing hardcoded localization
  • Loading branch information
maelchiotti authored Apr 12, 2024
1 parent 616dbf0 commit 3a0edc7
Show file tree
Hide file tree
Showing 9 changed files with 542 additions and 57 deletions.
10 changes: 10 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Contributing

## Localization

In order to improve or add support for a language, please follow these steps:

- Localized strings can be found in two different places:
- The `app_XX.arb` file located in [`lib/l10n`](lib/l10n) (where `XX` corresponds to the language code), that contains the vast majority of all strings. Please make sure that you do not localize any parameter name (ex: `{parameter}`) and that you do escape single quotes (ex: `I''m ok` instead of `I'm ok`).
- The [`hardcoded_localizations.dart`](lib/l10n/hardcoded_localizations.dart), that contains a few specific strings that need to be hardcoded.
- Localized strings can be generated with the `flutter gen-l10n` command. Check that the [`unstranslated.txt`](lib/l10n/untranslated.txt) file is empty, otherwise it will indicate which strings you did not translate.
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,26 @@ See more screenshots [here](assets/screenshots).

## Supported languages

- English: 100%
- French: 100%
- English
- French
- Turkish

To improve or add support for a language, please see [CONTRIBUTING.md](CONTRIBUTING.md#localization).

## Credits

- [Material Design Icons](https://github.com/google/material-design-icons) for the [notes](https://fonts.google.com/icons?selected=Material+Symbols+Outlined:notes) icon used for the logo.
- [Material Files](https://github.com/zhanghai/MaterialFiles) for the general design inspiration, and especially the logo and its color.
- [Simplenote](https://simplenote.com) for the general layout of the app and its basic features.

### Localization

- Turkish: [xe1st](https://github.com/xe1st).

## Contributing

Please see [CONTRIBUTING.md](CONTRIBUTING.md).

---

## Enhancements
Expand Down
7 changes: 5 additions & 2 deletions lib/l10n/app_localizations.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:intl/intl.dart' as intl;

import 'app_localizations_en.g.dart';
import 'app_localizations_fr.g.dart';
import 'app_localizations_tr.g.dart';

/// Callers can lookup localized strings with an instance of AppLocalizations
/// returned by `AppLocalizations.of(context)`.
Expand Down Expand Up @@ -88,7 +89,7 @@ abstract class AppLocalizations {
];

/// A list of this localizations delegate's supported locales.
static const List<Locale> supportedLocales = <Locale>[Locale('en'), Locale('fr')];
static const List<Locale> supportedLocales = <Locale>[Locale('en'), Locale('fr'), Locale('tr')];

/// No description provided for @app_name.
///
Expand Down Expand Up @@ -658,7 +659,7 @@ class _AppLocalizationsDelegate extends LocalizationsDelegate<AppLocalizations>
}

@override
bool isSupported(Locale locale) => <String>['en', 'fr'].contains(locale.languageCode);
bool isSupported(Locale locale) => <String>['en', 'fr', 'tr'].contains(locale.languageCode);

@override
bool shouldReload(_AppLocalizationsDelegate old) => false;
Expand All @@ -671,6 +672,8 @@ AppLocalizations lookupAppLocalizations(Locale locale) {
return AppLocalizationsEn();
case 'fr':
return AppLocalizationsFr();
case 'tr':
return AppLocalizationsTr();
}

throw FlutterError('AppLocalizations.delegate failed to load unsupported locale "$locale". This is likely '
Expand Down
Loading

0 comments on commit 3a0edc7

Please sign in to comment.