Miguel Vargas
05/24/2019, 7:38 PMText ("Hello World")
instead of Text (R.string.hello_world)
Leland Richardson [G]
05/24/2019, 7:49 PMlouiscad
05/24/2019, 7:55 PM'
manually. Raw string literals are better regarding this (except when you want to have double quotes at the beginning/end of a string, or triple+ quotes anywhere inside). I hope we get something better for l10n and i18n with what will work with Compose.karelpeeters
05/24/2019, 7:56 PMAdam Powell
05/24/2019, 7:56 PMlouiscad
05/24/2019, 8:02 PMAdam Powell
05/24/2019, 8:04 PMlouiscad
05/24/2019, 8:06 PMLeland Richardson [G]
05/24/2019, 8:06 PMt
and it would accept the default string translation, and some context string.
ie, Button(text=t("Sign Up!", "The sign up button on the main screen"))
. We then had a compiler plugin that would go find all instances of these, and as part of our CI process would communicate with our translation service with any new strings and put them in the queue to get translated. You could then have t(...)
return the translated string at runtime. The compiler can do the translations at build time, too, but we wanted to be able to push updated translations over the air, so the runtime conversion worked better.Adam Powell
05/24/2019, 8:06 PMLeland Richardson [G]
05/24/2019, 8:07 PMAdam Powell
05/24/2019, 8:09 PMRyan Mentley
05/24/2019, 8:09 PMFudge
05/24/2019, 8:09 PM"Sign Up" to "הירשם"
which is prone to typosLeland Richardson [G]
05/24/2019, 8:10 PMAdam Powell
05/24/2019, 8:10 PMLeland Richardson [G]
05/24/2019, 8:10 PMRyan Mentley
05/24/2019, 8:10 PM"The sign up button on the main screen"
is a really bad example of a context string 😛Leland Richardson [G]
05/24/2019, 8:10 PMRyan Mentley
05/24/2019, 8:11 PMLeland Richardson [G]
05/24/2019, 8:12 PMRyan Mentley
05/24/2019, 8:12 PMLeland Richardson [G]
05/24/2019, 8:12 PMAdam Powell
05/24/2019, 8:13 PMRyan Mentley
05/24/2019, 8:13 PMLeland Richardson [G]
05/24/2019, 8:13 PMFudge
05/24/2019, 8:14 PMAdam Powell
05/24/2019, 8:14 PMRyan Mentley
05/24/2019, 8:14 PMLeland Richardson [G]
05/24/2019, 8:15 PMAdam Powell
05/24/2019, 8:15 PMalexsullivan114
05/24/2019, 8:17 PMt
that Leland mentioned. Using that function in places you'd like to JVM test becomes challenging.
I have no idea how Compose could fix/change/work around that. Just a pain point I have.itnoles
05/24/2019, 8:17 PMAdam Powell
05/24/2019, 8:17 PMalexsullivan114
05/24/2019, 8:18 PMitnoles
05/24/2019, 8:18 PMFudge
05/24/2019, 8:19 PMAdam Powell
05/24/2019, 8:20 PMalexsullivan114
05/24/2019, 8:20 PMLeland Richardson [G]
05/24/2019, 8:29 PMalexsullivan114
05/24/2019, 8:35 PMLeland Richardson [G]
05/24/2019, 8:37 PMFudge
05/24/2019, 8:37 PM"The button was pressed %d times".localized(20)
russhwolf
05/24/2019, 8:38 PMLeland Richardson [G]
05/24/2019, 8:38 PMAdam Powell
05/24/2019, 8:38 PMLeland Richardson [G]
05/24/2019, 8:39 PMlouiscad
05/24/2019, 8:39 PMContext
). For example "Sign up" is likely to not need it and be usable anywhere in the app.
Some other strings need context though, but IMHO, to make translators lives easier, this context should have grouping, a hierarchy that the developers can define, which could have shorthand identifiers.
The place where the strings/translations would be defined for a context could embed comments (easier than xml comments hopefully), to give more information about the context.
The translators would read it to see where to navigate in the real app for example, or understand what a particular acronym stands for and the translations known to the developer (which maye code in English but may not be English native and have to translate an acronym from his language to English, potentially leaving misunderstandings or inaccuracies behind to the translator for additional languages).
I think grouping/hierarchy would be of great help for multiscreen apps, which are plenty, and would more valuable as your app gets a deep UI.Adam Powell
05/24/2019, 8:41 PMRyan Mentley
05/24/2019, 8:41 PMlouiscad
05/24/2019, 8:42 PM4 kids are playing 2 games.
, 1 kid is playing one game.
, Four kids are playing 1 game.
.alexsullivan114
05/24/2019, 8:46 PMlocalized
extension function since whatever tool iOS developers run specifically looks for NSLocalizedString
calls when it builds up the translationsitnoles
05/24/2019, 8:47 PMextension String {
var localized: String {
return NSLocalizedString(self, tableName: nil, bundle: Bundle.main, value: "", comment: "")
}
}
?Leland Richardson [G]
05/24/2019, 8:48 PMitnoles
05/24/2019, 8:49 PMalexsullivan114
05/24/2019, 8:50 PMNSLocalizedString
. So that extension function would result in just one localized string rather than all of the different uses of that function. Again, that could be wrong. iOS isn't my core strength. Also this is tangential to the conversation so we should probably drop it for nowFudge
05/24/2019, 8:52 PMitnoles
05/24/2019, 8:57 PMRyan Mentley
05/24/2019, 9:00 PMNot all strings need context (not thatDisagree here, every string should have context that describes the thing in as plain and jargon-free a way as possible in order to help translators make sense of it. "Sign up" is a very idiomatic phrase in English, imagine a language that doesn't have that phrase - would "Create account" be appropriate? The translator doesn't necessarily even know if your service has accounts, maybe it's a magazine or mailing list or something. Of course, you can probably get away with a lot less context if you have translators familiar with your product.). For example "Sign up" is likely to not need it and be usable anywhere in the app.Context
themishkun
05/24/2019, 9:26 PMSiyamed
05/25/2019, 12:55 AMghedeon
05/25/2019, 6:30 AMandroid.content.Context
. People are bending over and going great lengths just to workaround a simple case like unit testing formatted string (because of Context). https://kotlinlang.slack.com/archives/C5GB1NDGE/p1550527639020200?thread_ts=1550527639.020200&cid=C5GB1NDGEGil Goldzweig
05/26/2019, 5:43 AMEllen Shapiro
05/26/2019, 8:26 AMContext
is really helpful, but even when I’m using localized strings in iOS I find it really useful to use snake_case_keys
instead of Hardcoded untranslated string keys
Fudge
05/26/2019, 9:53 AMval `The sign up button on the main screen` = LocalizationString("Sign Up", "הירשם")
val `The login button on the main screen` = LocalizationString("Log in","היכנס")
But android doesn't support identifiers with spaces 😞val Thesignupbuttononthemainscreen
in some pre-compilation step thoughGil Goldzweig
05/26/2019, 10:51 AMRyan Mentley
05/28/2019, 10:21 PMghedeon
05/28/2019, 10:56 PMAndroidViewModel
or Context injection because it's a hack). Same with drawables. Ex: Based on some app logic, the VM is setting different icons to the view. As long as it's an R.drawable.ic_foo
it's ok, but applying color filter will require the context. To summarize: you want to take some decisions about the model of the view in the controller (VM) and before actual rendering.Leland Richardson [G]
05/28/2019, 10:58 PMRyan Mentley
05/28/2019, 11:05 PMghedeon
05/28/2019, 11:07 PMRyan Mentley
05/28/2019, 11:23 PMghedeon
05/28/2019, 11:32 PMRyan Mentley
05/28/2019, 11:40 PMLeland Richardson [G]
05/28/2019, 11:47 PMThus, the View is (and should be) responsible for formatting the data.Still though, if the formatting we are talking about is the “total price” line of a page that generates 100% of your business’s revenue, you want to be able to test it.
Ryan Mentley
05/28/2019, 11:56 PMLeland Richardson [G]
05/29/2019, 1:53 AMRyan Mentley
05/29/2019, 2:35 AM