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

Add English translation #47204

Merged
merged 2 commits into from
Feb 7, 2022
Merged

Add English translation #47204

merged 2 commits into from
Feb 7, 2022

Conversation

m-kuhn
Copy link
Member

@m-kuhn m-kuhn commented Feb 5, 2022

Finally QGIS will have an English translation. As the main language used
in international communication and most QGIS channels, this is an
important added value.
Jokes aside: this allows to have dedicated translations for plurals like
1 feature deleted vs 5 features deleted.

What we still need is a team that will update the strings containing
%n on the transifex en_US language
.

And a solution for the current requirement for a minimum of 35% translation to be published.

Finally QGIS will have an English translation. As the main language used
in international communication and most QGIS channels, this is an
important added value.
Jokes aside: this allows to have dedicated translations for plurals like
`1 feature deleted` vs `5 features deleted`.

What we still need is a team that will update [the strings containing
`%n` on the transifex en_US language](https://www.transifex.com/qgis/QGIS/translate/#en_US/qgis-application/114102351?q=text%3A%25n).
@github-actions github-actions bot added this to the 3.24.0 milestone Feb 5, 2022
@m-kuhn
Copy link
Member Author

m-kuhn commented Feb 5, 2022

And a solution for the current requirement for a minimum of 35% translation to be published.

@rduivenvoorde any smart ideas?

@rduivenvoorde
Copy link
Contributor

@rduivenvoorde any smart ideas?

Mmm, I think: I download the 'source', let me write a couple of lines of Python to 'copy' the 'source'-line to the 'translation line', maybe trying to ignore the lines with the plurals in it (and others which have an issue)... ?

I will try this later today...

@rduivenvoorde
Copy link
Contributor

The selected part I translated in Linguist, so:

  1. the 'type="unfinished"'-attributes is gone
  2. a copy of the text in source 'element' is in the 'translation' element

Screenshot-20220205130540-1145x658

No problem to do this with Python.

I'm thinking now (as the only goal is to reach the 35%?) to ONLY copy the 'straight'-translations, so everything with params in it (having { and } brackets) I skip.
Those are all potential plurals OR other parameters, which (without translation) will be taken as is...

Ok?

@m-kuhn
Copy link
Member Author

m-kuhn commented Feb 5, 2022

That looks very good. You can copy everything if it does not contain %n (which should give us a very good margin over 35%).

@rduivenvoorde
Copy link
Contributor

You can copy everything if it does not contain %n

Are you sure? That is just 83 lines.... Thought I heard Harrissou mention that we need to change something to %n first too. And I will not let it look that those are already translated.

So: Happy to skip stuff like:

<source>Tile request error (Status: %1; Content-Type: %2; Length: %3; URL: %4)</source>

<source>Executing “{}”</source>

or

<source>&lt;p align=&quot;right&quot;&gt;Algorithm author: {0}&lt;/p&gt;</source>

too, as I think we will hit that 35% easily?

@m-kuhn
Copy link
Member Author

m-kuhn commented Feb 5, 2022

At the moment, these 83 lines is just what we have in our codebase.
There are many occurrences of "%1 feature(s)" and similar, but those do not at the moment allow for plurals. It would be nice if someone could also fix those. In this case they will just appear as untranslated after having been modified (at least that's how I understand it).

@rduivenvoorde
Copy link
Contributor

Yes they will appear as 'untranslated', but that is ok. In that case the source-string will be taken, which is fine...

@m-kuhn
Copy link
Member Author

m-kuhn commented Feb 5, 2022

What I meant is:

If we have something like "%1 feature(s) making party" we can also copy the string to the translation. Because if tomorrow someone corrects that to "%n feature(s) making party" it will appear as untranslated again. And by having it translated today, it will help us to have a list of a few "untranslated" strings on transifex which we can easily go over. It would make sense to run this script from time to time, so if you don't mind adding that to the qgis source, we can redo this for the next release also.

@m-kuhn
Copy link
Member Author

m-kuhn commented Feb 5, 2022

or actually we ideally execute this every time when pushing sources to transifex (@jef-n probably knows when and how that happens)

@rduivenvoorde
Copy link
Contributor

Ok, clear. I will only skip the %n ones... And upload it to tx... and then you can restore the 35% in the config...
Lemme have a look

@rduivenvoorde
Copy link
Contributor

Mmm, I used the following script:

#!/usr/bin/env python3

import xml.etree.ElementTree as etree

def main():

    tree = etree.parse('./for_translation_QGIS_qgis-application_en_US.ts')
    root = tree.getroot()

    for element in root.iter("message"):
        source = element.find('source')
        translation = element.find('translation')
        if source.text and '%n' in source.text:
            print(f'Skipping "{source.text}" as it contains "%n"')
        else:
            translation.text = source.text
            # remove the 'type="unfinished"'-attribute IF available
            if 'type' in translation.attrib:
                translation.attrib.pop('type')

    # grmph, lxml is eating de DOCSTRING
    tree.write('./translated_QGIS_qgis-application_en_US.ts', xml_declaration=True, encoding='UTF-8')


if __name__ == "__main__":
    main()

in which for_translation_QGIS_qgis-application_en_US.ts is the file you can download as translator/coordinator.
It runs fine, looks good (AFTER adding the DOCSTRING again), and uploads fine...
But I do not see the right 'score' of 99% or so yet... @DelazJ @jef-n one of you has an idea? Or should we just wait...

Happy to download the ts files for other QGIS versions too, 'translate' them and upload them...

@m-kuhn
Copy link
Member Author

m-kuhn commented Feb 5, 2022

Looks all good now

@rduivenvoorde
Copy link
Contributor

Mmm, 91.77% is lower then I would expect with just 83 lines skipped. But ala.

And apparently the other versions take also over all string....

Maybe I will 'translate' 3.22 again to upper it's percentage, as that is our upcoming LTR...

@m-kuhn
Copy link
Member Author

m-kuhn commented Feb 5, 2022

I didn't have any intentions to backport, do you think it should be?

@rduivenvoorde
Copy link
Contributor

I didn't have any intentions to backport, do you think it should be?

Ah, mmm I don't know... I was thinking this was done because of the upcoming LTR... Not sure if it could break anything.... Better ask others?

@m-kuhn
Copy link
Member Author

m-kuhn commented Feb 5, 2022

Yes, the risk is minimal, but so is the benefit. I'd stay on the safe side but if someone feels the need that this should be backported I won't block anything.

@nyalldawson
Copy link
Collaborator

@m-kuhn

how does this PR handle the plural forms which don't have "(s)" in the string? (.e.g "%n vertices deleted"). Does anything special need to be done for those?

@nyalldawson
Copy link
Collaborator

Ahh, i guess that comes under the todo: "a solution for the current requirement for a minimum of 35% translation to be published."?

@m-kuhn
Copy link
Member Author

m-kuhn commented Feb 7, 2022

@m-kuhn

how does this PR handle the plural forms which don't have "(s)" in the string? (.e.g "%n vertices deleted"). Does anything special need to be done for those?

They are not different at all and already handled fine. When a %n is in the text, transifex lets you add 2 translations. No magic involved.
The todo is done (thx to @rduivenvoorde ).
The only thing missing is an approval.

Copy link
Collaborator

@nyalldawson nyalldawson left a comment

Choose a reason for hiding this comment

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

approved

@agiudiceandrea
Copy link
Contributor

agiudiceandrea commented Jun 29, 2023

Hi @m-kuhn, it looks like this PR causes a double listing of "American English":
image

since the code in

QStringList QgsOptions::i18nList()
{
QStringList myList;
myList << QStringLiteral( "en_US" ); //there is no qm file for this so we add it manually
QString myI18nPath = QgsApplication::i18nPath();
QDir myDir( myI18nPath, QStringLiteral( "qgis*.qm" ) );
doesn't expect the presence of a qgis_en_US.qm file.

See #53667.

The presence of qgis_en_US.qm file (if not constatly updated) may be also the cause of the issue #53592 (comment) and/or #53652.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants