TriliumNext / Notes

Build your personal knowledge base with TriliumNext Notes
GNU Affero General Public License v3.0
642 stars 31 forks source link

internationalization (i18n) / multiple language support #338

Open meichthys opened 4 weeks ago

meichthys commented 4 weeks ago

Discussed in https://github.com/orgs/TriliumNext/discussions/240

Originally posted by **eliandoran** July 18, 2024 One of the core aspects of Trilium that is missing is the fact that it is an English-only software. There are solutions such as @Nriver 's repo which work by replacing the hard-coded messages within the application via regular expressions. Speaking of which, @Nriver , would you be willing to help us with setting up Chinese for the application? On my side I would prefer a different method which involves adding multilanguage support directly in the application instead of doing it at build time, however your existing expertise plus translations would go a long way. What do you think?
JYC333 commented 4 weeks ago

Language switcher is merged actually. #330 And there is already one PR merged regarding Chinese translation, not sure whether all messages are translated. #264

Nriver commented 4 weeks ago

About 60% has been translated.

hasecilu commented 3 weeks ago

On #349 I made an initial step to have Spanish translation, I'll be happy to test next beta release and find potential fixes on strings.

hasecilu commented 3 weeks ago

To help on the translation for new languages I made a small script to use trans command from translate-shell package. Now most of the work is to review translations are good and fix bad translations.

#!/usr/bin/env bash

INPUT_FILE=en.json
OUTPUT_FILE=es.json

while IFS= read -r line; do
    # Extract the string between ': "' and '"'
    extracted_string=$(echo "$line" | awk -F'": "' '{split($2, a, "\""); print a[1]}')

    if [ -z "$extracted_string" ]; then
        output_line="$line"
    else
        translated_string=$(trans :es --brief "$extracted_string")
        output_line=${line//$extracted_string/$translated_string}
        # output_line=$(echo "$line" | sed "s/$extracted_string/$translated_string/g")
    fi
    echo "$output_line" >>"$OUTPUT_FILE"
done <"$INPUT_FILE"