Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translation key migration #367

Merged

Conversation

LouisDelbosc
Copy link
Contributor

Related issue #336

I did not add the script I used. If you wish for me to commit it, please tell me where should I put it.

@yohanboniface
Copy link
Contributor

Just to make it clear, this commit is only about switching from arbitrary keys to using back the English strings as keys, right ?

Next to that, we want a script that will generate (and keep up to date) the various i18n json files, and this script should be commited and integrated to the i18n workflow, correct @LouisDelbosc ?

@LouisDelbosc
Copy link
Contributor Author

The current PR is about migration from one translation key standard to a new one, one where we can extract translation automatically.

I don't know what strategy for automation translation we adopt, however it'll be easily automate-able (❓)

@LouisDelbosc
Copy link
Contributor Author

Hmm test are breaking because I have an issue with i18next.
It seems it has trouble looking at some keys that are using specials characters such as :.
Do you have any idea how to fix it ?

Otherwise I'll look at it next Tuesday.

@berhalak berhalak self-assigned this Dec 9, 2022
@berhalak
Copy link
Contributor

berhalak commented Dec 9, 2022

Hmm test are breaking because I have an issue with i18next. It seems it has trouble looking at some keys that are using specials characters such as :. Do you have any idea how to fix it ?

Otherwise I'll look at it next Tuesday.

The : character is interpreted as a namespace selector. I'm checking how we can disable it. I'm afraid we will have the same problem with ..

@berhalak
Copy link
Contributor

berhalak commented Dec 9, 2022

I have a fix for this, just waiting for tests and will push a PR.

@berhalak
Copy link
Contributor

berhalak commented Dec 9, 2022

This PR hopefully should address the issue you are facing.

@berhalak
Copy link
Contributor

@LouisDelbosc the fix has been merged, it should now be possible to use natural keys with : or . characters.

@LouisDelbosc
Copy link
Contributor Author

Thank you @berhalak. Do you have an idea where the should I put the script to generate the translations keys ? Do you have a folder where you put this kind of code ?

@berhalak
Copy link
Contributor

Yes, most scripts are in /buildtools folder.

@berhalak
Copy link
Contributor

What is a plan for the French translation file?

@LouisDelbosc
Copy link
Contributor Author

We'll do it later. Tomorrow I'll put the script in /buildtools and a command line in the package.json file.
@yohanboniface correct me if I'm wrong but I think french translations will be done in another PR ?

@berhalak berhalak self-requested a review December 15, 2022 14:46
@yohanboniface
Copy link
Contributor

@yohanboniface correct me if I'm wrong but I think french translations will be done in another PR ?

We'll finish the translations in another PR yes, but we'll need the French json keys to be updated accordingly, is that in your radar ?

buildtools/generate_translation_keys.js Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
static/locales/en.client.json Outdated Show resolved Hide resolved
buildtools/generate_translation_keys.js Outdated Show resolved Hide resolved
app/client/models/AppModel.ts Outdated Show resolved Hide resolved
"Clear cell": "Clear cell",
"Clear values": "Clear values",
"Copy anchor link": "Copy anchor link",
"Delete {{count}} columns_one": "Delete {{count}} columns",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something is off with the script, every resource that needs pluralization is wrong. For example here, for one column it should say "Delete column".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I stated in the issue #336, we cannot automatically determine what would be the plural or singular form only by looking at the keys/texte.
You might ask "why bother with plurals and singular" ? Depending on the language, we could have multiples plurals variables, for one, for two maybe for three, some language may have edge case.

Since we cannot determine the value from the key, we decide to put in key the plural form and correct by hands the value for singular or other case.

I'll do the correction by hands on the singular keys which are off

@yohanboniface
Copy link
Contributor

Since we cannot determine the value from the key,

Given we are using our own helper (makeT), why not dealing with both key in it, and then generating both singular and plural automatically ?

I'm thinking about something like this:

makeT("my singular text", count={myvar}, plural_form="my {{myvar}} plural form")

@LouisDelbosc
Copy link
Contributor Author

Since we cannot determine the value from the key,

Given we are using our own helper (makeT), why not dealing with both key in it, and then generating both singular and plural automatically ?

I'm thinking about something like this:

makeT("my singular text", count={myvar}, plural_form="my {{myvar}} plural form")

It would be possible but since there is multiples plural_form possible, the interface should be more like:

makeT("my singular text",
  {
    count,
    two: "my plural for {{count}}",
    three: "my {{count}} form",
    other: "{{count}} form",
  })

with one, two three and others the part after they key for i18next to know the plural form : https://www.i18next.com/translation-function/plurals

@yohanboniface
Copy link
Contributor

It would be possible but since there is multiples plural_form possible, the interface should be more like

What about just supporting one and many for a first step ?

Copy link
Contributor

@berhalak berhalak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found a couple of keys that are still using old schema. Regarding the build error, you can rebase on main branch, it should be fixed there.

"Trash is empty.": "Trash is empty.",
"Unpin Document": "Unpin Document",
"Workspace not found": "Workspace not found",
"You are on the {{siteName}} site. You also have access to the following sites:": "You are on the {{siteName}} site. You also have access to the following sites:",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those two should be merged (version for the personal site and for the team site).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How should it be merged ? We no longer using context and as you can see in the code below, both are still used.

Screenshot 2022-12-20 at 10 49 11

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahhh, so the condition is wrong. Those two should be swapped.

"FullCopies": "Permission to access the document in full when needed",
"AttributeNamePlaceholder": "Attribute name",
"Everyone": "Everyone",
"EveryoneElse": "Everyone Else",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This key is still used in ACL page.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are not really removed either. Here the new AccessRules translations keys:

"AccessRules": {
    "Add Column Rule": "Add Column Rule",
    "Add Default Rule": "Add Default Rule",
    "Add Table Rules": "Add Table Rules",
    "Add User Attributes": "Add User Attributes",
    "Allow everyone to copy the entire document, or view it in full in fiddle mode.\nUseful for examples and templates, but not for sensitive data.": "Allow everyone to copy the entire document, or view it in full in fiddle mode.\nUseful for examples and templates, but not for sensitive data.",
    "Allow everyone to view Access Rules.": "Allow everyone to view Access Rules.",
    "Attribute name": "Attribute name",
    "Attribute to Look Up": "Attribute to Look Up",
    "Checking...": "Checking...",
    "Condition": "Condition",
    "Default Rules": "Default Rules",
    "Delete Table Rules": "Delete Table Rules",
    "Enter Condition": "Enter Condition",
    "Everyone": "Everyone",
    "Everyone Else": "Everyone Else",
    "Invalid": "Invalid",
    "Lookup Column": "Lookup Column",
    "Lookup Table": "Lookup Table",
    "Permission to access the document in full when needed": "Permission to access the document in full when needed",
    "Permission to view Access Rules": "Permission to view Access Rules",
    "Permissions": "Permissions",
    "Remove column {{- colId }} from {{- tableId }} rules": "Remove column {{- colId }} from {{- tableId }} rules",
    "Remove {{- tableId }} rules": "Remove {{- tableId }} rules",
    "Remove {{- name }} user attribute": "Remove {{- name }} user attribute",
    "Reset": "Reset",
    "Rules for table ": "Rules for table ",
    "Save": "Save",
    "Saved": "Saved",
    "Special Rules": "Special Rules",
    "Type a message...": "Type a message...",
    "User Attributes": "User Attributes",
    "Users": "Users"
  },

I count 32 keys for both the new AccessRules and the old translations keys.

"UpdatingRecordLayout":"Updating record layout."
},
"RecordLayoutEditor": {
"AddField":"Add Field",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those keys as still used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are not really removed. I removed the folder key (in this case components) to have a flatter file. The new RecordLayoutEditor translations look like this :

  "RecordLayoutEditor": {
    "Add Field": "Add Field",
    "Create New Field": "Create New Field",
    "Show field {{- label}}": "Show field {{- label}}",
    "Save Layout": "Save Layout",
    "Cancel": "Cancel"
  }

Of course the file has been updated and there the key named AddField is replaced by Add Field

@LouisDelbosc
Copy link
Contributor Author

@berhalak I don't have the errors there is on the CI locally. Was I just lucky ?

@berhalak
Copy link
Contributor

@berhalak I don't have the errors there is on the CI locally. Was I just lucky ?

I'm restarting the last build, can't reproduce the error locally.

Copy link
Contributor

@berhalak berhalak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @LouisDelbosc, it looks great. I will merge this PR after those conflicts are resolved. Sorry for the delay, but this is a big PR, and we need to synchronize it with the release schedule.

@paulfitz
Copy link
Member

Just to be clear, is the next step for this PR for @LouisDelbosc to resolve the merge conflicts?

Someone recently volunteered to do a Portuguese translation and is already testing a weblate project https://hosted.weblate.org/projects/grist/client/. I don't want to slow them down, so I'm willing to fix up anything that needs fixing to adapt any work they do. It would be better to get this PR through sooner rather than later though, both for this reason and because it touches a lot of files (so merge conflicts will continue to accumulate).

That said it is a holiday period, Happy New Year everyone, looking forward to 2023 bringing a very multilingual Grist :-)

@yohanboniface
Copy link
Contributor

@paulfitz hey :)

Just to be clear, is the next step for this PR for @LouisDelbosc to resolve the merge conflicts?

I'd say so!

@LouisDelbosc is indeed in holiday ;)
I've had a look yesterday to see if I could resolve the merge conflicts so to make this PR land and not to have more conflicts while the main branch continues, but the conflicts were too nested in the code for me :/

@berhalak
Copy link
Contributor

berhalak commented Jan 3, 2023

Thanks @LouisDelbosc !

@LouisDelbosc
Copy link
Contributor Author

There was new conflicts I fixed. I'd like this PR to be merged so I don't have to fix conflict as a job 😅

@berhalak berhalak merged commit de1001f into gristlabs:main Jan 3, 2023
@vviers vviers added the anct label Jul 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants