HospitalRun / hospitalrun-frontend

Frontend for HospitalRun
https://staging.hospitalrun.io
MIT License
6.8k stars 2.18k forks source link

Adding missing translations (with Weblate) #2104

Open rodzy opened 4 years ago

rodzy commented 4 years ago

🚀 Feature Proposal

To add some of the missing translations on the script files, can I start working on them or you guys planning on doing it a different way?

Motivation

I've seen some traction for this repository on some Facebook front-end groups and they were talking about the missing languages , so I've been studying the code and would like to collaborate

matteovivona commented 4 years ago

Hi @rodzy. We are thinking of integrating Crowdin for easier translation management. Do you maybe have any experience at the configured level?

rodzy commented 4 years ago

Hi @tehKapa. I'm catching up with the Crowdin documentation right now. As soon I have it done I notify you guys on Slack

matteovivona commented 4 years ago

The main issue is finding a way to implement a translation template to the current code structure.

marcosvega91 commented 4 years ago

The best way in this case is to use JSON file instead of ts files for translations

matteovivona commented 4 years ago

And use this https://www.npmjs.com/package/react-i18next for import json?

marcosvega91 commented 4 years ago

Why do you want to add it ? To use JSON files? If I remember well i18next is enough

matteovivona commented 4 years ago

You're probably right (I'm not a developer, I'm in charge of management and CI/CD).

Btw, I leave here a reference link https://github.com/i18next/react-i18next/issues/472

marcosvega91 commented 4 years ago

It is not a problem :). About the implementation I think that with .json is simpler than with .ts. As i suggested here #1919 Docusaurus is using this service. @rodzy I think that you can take a look their implementation.

rodzy commented 4 years ago

I was messing with the .ts files yesterday and it's definitely challenging, because Crowdin only uses string recognition and some times picks the type properties as strings that in mind changes the flow results on not displaying any data on the end application. I might try using .json , thx for the suggestion on Docusaurus @marcosvega91, I'm definitely checking their implementation.

marcosvega91 commented 4 years ago

I have made a little test about this point. Crowdin has a built-in integration with github. You can choose the branch from which Crowdin should be synched then Crowdin will create PR with translations. I think that the only thing to do is to create JSON files and than someone should configure Crowdin

fox1t commented 4 years ago

Ok. I am going to explore Crowdin this evening and then we will make the final decision. Thanks for working on this. Speaking about TS vs JSON, since now there were any difference for us but TS was more flexible, however if JSON integrates better with external platforms we are going to refactor the translations.

rodzy commented 4 years ago

Speaking of Crowdin configuration, the other day I was digging a bit on it an got some things done on a test crowdin.yaml file with the Crowdin CLI using my personal account.

From that there are some thing to consider:

  1. Having a public HospitalRun project or an organization on https://crowdin.com would be great from the start to make the config file way faster and generate the general API key for the organization and the project repository itself.

  2. Having just one JSON file with en-US translation and from that file we can generate all the other translations, Crowdin generates the other translations into the specified folders.

  3. To make it better to work with dynamic data with the current translation module (i18n) that uses the TypeScript files already defined, we can modify the current .ts files or implement a interface or a class to store the data into TypeScript.

Example:

import jsonObject from './todo.json'; 

// Defining our Todo class 
class Todo { 
    userId: number; 
    id: number; 
    title: string; 
    done: boolean; 
}   
// Object.assign() will clone jsonData into 
// Todo class object Storing the new class 
// object in a typescript variable 
let newTodo = Object.assign(new Todo(), jsonData); 

// Logging the output onto the console 
console.log(newTodo); 

Output:

Todo {
  userId: 1,
  id: 1,
  title: 'Some data',
  done: true
}
comradekingu commented 4 years ago

@tehKapa Stay far away from Crowdin, see https://github.com/jitsi/jitsi-meet/issues/5056#issuecomment-612239691 Use Weblate instead :)

matteovivona commented 4 years ago

@comradekingu thanks for the advice!

matteovivona commented 4 years ago

Here we are! Weblate support has lightning-fast activated a Libre account https://hosted.weblate.org/projects/hospitalrun/

@rodzy @marcosvega91 unfortunately it was better to change service, I hope that the work done on Crowdin can be reused

comradekingu commented 4 years ago

@tehKapa Better idea that discovering the quality isn't good. I can help populate it if you add https://hosted.weblate.org/user/kingu/ as an admin :) Only started helping projects this way, but got two projects up and running in as many days.

fox1t commented 4 years ago

Thanks, @comradekingu for pointing this out. As a project that will be used by final users, we need to pay more attention to who we rely upon!

comradekingu commented 4 years ago

I couldn't agree more, we should watch out for this kingu guy ;)

matteovivona commented 4 years ago

@comradekingu I've added you to Weblate project

comradekingu commented 3 years ago

So from what I can tell .ts Qt Linguist files are supposed to be different from the ones found in this repo. No luck adding those.

Start tag expected, '<' not found, line 1, column 1 (<string>, line 1) src/shared/locales/de/translations/actions/index.ts: Start tag expected, '<' not found, line 1, column 1 (<string>, line 1) src/shared/locales/enUs/translations/actions/index.ts: Start tag expected, '<' not found, line 1, column 1 (<string>, line 1) src/shared/locales/es/translations/actions/index.ts: Start tag expected, '<' not found, line 1, column 1 (<string>, line 1) src/shared/locales/fr/translations/actions/index.ts: Start tag expected, '<' not found, line 1, column 1 (<string>, line 1) src/shared/locales/id/translations/actions/index.ts: Start tag expected, '<' not found, line 1, column 1 (<string>, line 1) src/shared/locales/it/translations/actions/index.ts: Start tag expected, '<' not found, line 1, column 1 (<string>, line 1) src/shared/locales/ja/translations/actions/index.ts: Start tag expected, '<' not found, line 1, column 1 (<string>, line 1) src/shared/locales/ptBr/translations/actions/index.ts: Start tag expected, '<' not found, line 1, column 1 (<string>, line 1) src/shared/locales/ru/translations/actions/index.ts: Start tag expected, '<' not found, line 1, column 1 (<string>, line 1) src/shared/locales/zhCN/translations/actions/index.ts: Start tag expected, '<' not found, line 1, column 1 (<string>, line 1)
matteovivona commented 3 years ago

what are the steps you have done?

comradekingu commented 3 years ago

I added a component with settings I think would otherwise have worked. Tried both with wildcards for component and language, and adding just one component at a time. I can post the settings if you like.

matteovivona commented 3 years ago

yep, it would be useful

client-side96 commented 3 years ago

Hi guys, I'm new to this project and to be honest also new to "contributing on GitHub" in general. I saw that there are missing some German translations and wanted to ask if I could help you adding them ?

matteovivona commented 3 years ago

Hi @client-side96. We wanted to use Weblate to make translation easier, but everything remained on standby. Actually, we manually translate files with the various labels, like this PR: https://github.com/HospitalRun/hospitalrun-frontend/pull/2661