minetest-world / mtlauncher

GNU Lesser General Public License v2.1
5 stars 3 forks source link

Add translations #19

Closed Miniontoby closed 7 months ago

Miniontoby commented 1 year ago

You should add translations to it.

I might be able to help if I take time for it. I am a webdev, so I could try to add it!

https://www.npmjs.com/package/translate will be useful.

I can help with translating into Dutch if you put it on crowdin or weblated or such like website thingy.

recluse4615 commented 1 year ago

https://github.com/kaisermann/svelte-i18n svelte-i18n is pretty much the gold standard as far as translations go for svelte

there is, however, a question to answer: how do we handle languages? https://github.com/tauri-apps/tauri/issues/2735 seems to suggest that navigator.language will always default to english in a tauri app, and at a quick glance i couldn't find any other way to get the current system language via tauri

anything that we'd do would probably (for now, at least, until either tauri implements a locale func or i find one if it does exist lol) need to rely on #4 which requires a lot of work in its own right 😩

we can probably start some of the work now, and just "move over" once we have a solution in place, but there's still a lot of text that may change (and a lot of content that can't be translated, for instance game/server content)

Miniontoby commented 1 year ago

I did some research and found a way to do it!

Use this in main.rs:

use current_locale::*;

(...)

#[tauri::command]
fn get_user_language() -> String {
  let current_locale = current_locale::current_locale();
  if (current_locale.is_ok()){
    return current_locale.ok().unwrap();
  }
  return "en-US".to_string();
}

And add current_locale = "*" to [dependencies] in Cargo.toml

And then just do:

import { invoke } from '@tauri-apps/api/tauri';
async function getLanguage(){
    language = await invoke('get_user_language');
    return language;
}

I have tested it and it did return nl-NL for me, cause I am Dutch

recluse4615 commented 1 year ago

we can probably move forwards with that as a solution, although i'd limit the scope of what we import from current_locale just as a safeguard (ie use current_locale::current_locale)

Miniontoby commented 1 year ago

Yeah sure!

Can you then add that i18n package? I am not sure if I can implement it correctly, unless you can provide me enough information, then I could do it...

recluse4615 commented 1 year ago

i'll work on the base of this all over the weekend - won't have any time until then

Miniontoby commented 1 year ago

Hey,

Time has passed and the svelte-i18n does work with tauri. I have tested it on my app!

I will also try adding it to the mtlauncher, but yeah I will have to make another branch for it cause yeah you still haven't merge the previous changes or giving any updates on the changed review thingys.

Miniontoby commented 8 months ago

I have made everything translatable in the PR

Once it is merged (the #25 or the #24 since that one now also includes translations) you can create a project over at like crowdin and then import the en and nl files/folders

recluse4615 commented 7 months ago

Closing this as the work was added in the mods tab PR