-
Notifications
You must be signed in to change notification settings - Fork 6
Setup Internationalization #26
base: main
Are you sure you want to change the base?
Conversation
829cb0e
to
98af20b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider add an extension like this
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
extension AppLocalizationsExt on BuildContext {
AppLocalizations get l10n => AppLocalizations.of(this);
}
Then localized strings can be get by using context.l10n.initializing
instead of AppLocalizations.of(context).initializing
.
lib/l10n/app_en.arb
Outdated
@@ -0,0 +1,10 @@ | |||
{ | |||
"initializing": "Initializing...", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I seems like this file could quite fast get messy if we don’t have some structure.
@TouHouNo or @prinshamlet do you have any good advice or experience on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's probably good to have some convention in the names for the structure that includes "module names", like using "intro_page__text_name" 🤔
@rh-concordium might also have some insight on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I would suggest grouping related texts keys according to functionality using dot notation. E.g., "onboarding.intro_text", "onboarding.terms_and_conditions", etc. Then you could use additional additional dots if you want to further subgroup your functionality/texts.
I wouldn't use dots for general terms like "Ok", "Continue", etc, though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the dot notation, but it seems impossible with the current setup.
Generating synthetic localizations package failed with 1 error:
Exception: Invalid ARB resource name "terms_and_conditions.before_you_begin" in LocalFile:
'/home/hjort/Projects/concordium-wallet/lib/l10n/app_en.arb'.
Resources names must be valid Dart method names: they have to be camel case, cannot start with a number or
underscore, and cannot contain non-alphanumeric characters.
We can do camelCase with underscore as the separator: onboarding_termsAndConditions
? 🤔
lib/l10n/app_en.arb
Outdated
"initializing": "Initializing...", | ||
"cont": "Continue", | ||
"before_you_begin": "Before you begin", | ||
"intro_text0": "Before you start using the Concordium Mobile Wallet, you have to set up a passcode and optionally biometrics.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we use more descriptive names instead of _0 and _1?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I'm not sure there are more descriptive names, it's just one text split into two paragraphs.
I think the right thing is merging them? 🤔
(I've tried doing that)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpicking: Is "cont" a common abreviation for "Continue" at concordium? Otherwise, I would just use the full name as the key for readability
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not a common abbreviation.
I did it because both Continue
and continue
are "bad" keys. Continue
is rejected by the generator and continue
causes compile issues because it is a keyword.
Maybe there is a better solution though? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PS: In my old job we were using string xml files, which is why we could get away with dots and we could use whatever keys we liked (and the reason we were using string xml files was that we had a huge language file already 5000+ words that was shared with other native apps)
f41b214
to
b21c989
Compare
lib/l10n/app_en.arb
Outdated
@@ -0,0 +1,10 @@ | |||
{ | |||
"initializing": "Initializing...", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I would suggest grouping related texts keys according to functionality using dot notation. E.g., "onboarding.intro_text", "onboarding.terms_and_conditions", etc. Then you could use additional additional dots if you want to further subgroup your functionality/texts.
I wouldn't use dots for general terms like "Ok", "Continue", etc, though
lib/l10n/app_en.arb
Outdated
"initializing": "Initializing...", | ||
"cont": "Continue", | ||
"before_you_begin": "Before you begin", | ||
"intro_text0": "Before you start using the Concordium Mobile Wallet, you have to set up a passcode and optionally biometrics.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpicking: Is "cont" a common abreviation for "Continue" at concordium? Otherwise, I would just use the full name as the key for readability
Purpose
Setup internationalization, and show of usage. (using terms and condition screen)
Changes
flutter_localizations
andintl
.Checklist
hard-to-understand areas.