Closed AsterNighT closed 8 months ago
Also, to replace all occurrences of raw texts in the code is quite some labor. Help or advices on how to do that in a smart way is appreciated.
Nice work! In my opinion, put i18s into SFC is better. The locale messages are used as the local scope in SFC. So he probability of conflict is smaller. Besides , translators can intuitively know where the text will be placed.
The locale setting should be stored in the settings. Maybe there will be a new field in settings, but it won't break compatibility. We can give it a default value to avoid crashing during deserialization.
like this
pub enum Locale{
cn,
eng
}
#[derive(Debug, Serialize, Deserialize)]
pub struct Settings {
pub prompt_when_not_described: bool,
pub extra_backup_when_apply: bool,
#[serde(default = Locale::cn)]
pub locale: Locale,
}
Nice work! In my opinion, put i18s into SFC is better. The locale messages are used as the local scope in SFC. So he probability of conflict is smaller. Besides , translators can intuitively know where the text will be placed.
The locale setting should be stored in the settings. Maybe there will be a new field in settings, but it won't break compatibility. We can give it a default value to avoid crashing during deserialization.
like this
pub enum Locale{ cn, eng } #[derive(Debug, Serialize, Deserialize)] pub struct Settings { pub prompt_when_not_described: bool, pub extra_backup_when_apply: bool, #[serde(default = Locale::cn)] pub locale: Locale, }
LGTM, the SFC style i18n seems to require some extra settings in bundler, I'll look into it.
Ok, this is a bit more complicated than I expected.
SFC works pretty well on the templates, but there are some texts outside of templates, as https://github.com/mcthesw/game-save-manager/blob/50abd0c71497fcc2171e380bf26b26033513a8dc/src/views/Home.vue#L64
If we use SFC i18n, the strings will be put in a local scope, as far as I learned there seems to be no good way to access a local i18n scope in a script block. Now in the code this is done via accessing the global scope, as is suggested here https://github.com/intlify/vue-i18n-next/issues/310.
I guess I'll fall back to the traditional locale files if there's no workaround.
Separate file is good enough, it's ok to use the traditional way
nice
I would like to add you to the thanks list. Can I use the GitHub username directly? You can also provide me a nickname
I would like to add you to the thanks list. Can I use the GitHub username directly? You can also provide me a nickname
Sure thing. AsterNighT will do.
This is a first step towards #32
For now it only covers Settings.vue. And there are choices to make:
cn.json
to store all the strings, put i18s string directly into SFC. (See https://vue-i18n.intlify.dev/guide/advanced/sfc.html) Which is the better practice?If all there trouble can be resolved I suppose a i18n key can be returned from rust calls which maps to an explaination to the error.
Signed-off-by: AsterNighT asternight@outlook.com