-
-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add remaining missing mobile translations #857
Conversation
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.
Thanks.
There is also the Join a game
from the custom game creation screen that is missing.
Ah, we already have a string for that actually, apparently I just forgot to use it |
9b34bcb
to
93a93ed
Compare
@tom-anders can you solve the conflicts please? |
93a93ed
to
fc45919
Compare
@@ -527,7 +527,7 @@ class _HelloWidget extends ConsumerWidget { | |||
), | |||
const SizedBox(width: 5.0), | |||
Text( | |||
'Hello${user != null ? ', ' : ''}', | |||
'${context.l10n.mobileHello}${user != null ? ', ' : ''}', |
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.
@veloce This should probably be fine for most languages, but I'm sure there are some languages where "Hello, %s" does not make any sense, we might want to revisit this at some point
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.
@tom-anders that is because we use the UserFullNameWidget
.
Now that I think of it we should make it right from the start and have a parameterised message such as helloX
: Hello, <name>
.
We can adapt the HelloWidget later to show the flair for instance.
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.
Ok, so the string is now 'Hello %s' and I added a special case in the translation generation, making sure that the %s is not converted to a function parameter. This way, we can instead split the (localized) string at '%s' and put the UserNameWidget between the two resulting parts.
Done 👍 |
e42761c
to
4dffeb9
Compare
style: style, | ||
), | ||
if (user != null) UserFullNameWidget(user: user, style: style), | ||
if (user != null && greetingParts.length == 2) ...[ |
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.
Not sure about this. Is the greetingParts.length
always 2?
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, according to the flutter docs:
A non-empty match at the start or end of the string, or after another match, is not treated specially, and will introduce empty substrings in the result
So we'll always get 2 here, as long as '%s' is somewhere in the string, including start and end. (If not, it's a translation issue, the comment says to always include the %s)
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 think it's a common use case (inclusion of a widget instead of string in a translation) so it should be factored out in a utility function.
And this function should have unit tests.
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.
Ah yes good point, will do 👍
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.
Ok, added a utility function
IList<Widget> replaceL10nPlaceholderWithWidget<T extends Widget>(
String Function(String) l10nWithReplacement,
T widget, {
TextStyle? textStyle,
})
To avoid empty text widgets, this now also catches the case where the placeholder is at start the start or end and only adds one instead of two Text Widgets in that case
b01a34c
to
88c2ead
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.
One remaining change about the signature of the utility function and we're good I think :)
88c2ead
to
4f63142
Compare
4f63142
to
0ce1e58
Compare
This solves #753
I didn't add any translation for the Puzzle Storm description, since the string is copied from lila (which does not have a translation yet either)