python-fluent icon indicating copy to clipboard operation
python-fluent copied to clipboard

how can I extract translation percentage?

Open Jibec opened this issue 6 years ago • 8 comments

hello, is there a way to have the translation progress of a fluent file?

for po files, I'm using this: http://docs.translatehouse.org/projects/translate-toolkit/en/latest/commands/pocount.html

can I use python-fluent to do something equivalent?

Jibec avatar May 21 '19 06:05 Jibec

You can do that with compare-locales.

I found the docs for that tool a bit impenetrable, particularly for l10n.toml, which is really a separate issue, but eventually managed to get something working with a l10n.toml file like this:

basepath = "."

locales = [
    "en",
    "tr",
]

[[paths]]

reference = "myapp/locales/en/**/*.ftl"
l10n = "myapp/locales/{locale}/**/*.ftl"
locales = [
    "tr",
]

I'll leave this ticket open as a reminder to add something to the docs about this.

spookylukey avatar May 21 '19 09:05 spookylukey

Le 2019-05-21 11:29, Luke Plant a écrit :

You can do that with compare-locales [1].

Thanks a lot! This saves me a lot of trouble...

Is this file the right one? https://hg.mozilla.org/l10n/mozilla-central/file/tip/browser/locales/l10n.toml If so, you may add a reference to this repository in the documentation.

Jibec avatar May 21 '19 12:05 Jibec

The file format is documented at https://moz-l10n-config.readthedocs.io/en/latest/fileformat.html, though there might be a few quirks.

The code for compare-locales is at https://hg.mozilla.org/l10n/compare-locales, so you could wrap your own project management and discovery around that.

Pike avatar May 21 '19 12:05 Pike

Oh, sorry, I forgot to tell you what is my goal: to measure the translation statistics of Mozilla Firefox. That's why I was searching for an existing toml file. Without an existing toml file, I would use the python translation-finder package and produce one manually, but if one exists already, I'm pleased to reuse it :)

Jibec avatar May 21 '19 12:05 Jibec

So, for Firefox, we're using cross-channel localization, and our reference strings are at https://hg.mozilla.org/l10n/gecko-strings/.

The l10n config file for Firefox in there is https://hg.mozilla.org/l10n/gecko-strings/file/default/_configs/browser.toml.

Pike avatar May 21 '19 12:05 Pike

Le 2019-05-21 14:24, Axel Hecht a écrit :

So, for Firefox, we're using cross-channel localization, and our reference strings are at https://hg.mozilla.org/l10n/gecko-strings/.

The l10n config file for Firefox in there is https://hg.mozilla.org/l10n/gecko-strings/file/default/_configs/browser.toml.

Perfect, thank you, I think I have all needed for firefox. Where can I ask other question if needed? I assume I may have similar questions with Thunderbird and maybe with other applications.

Jibec avatar May 21 '19 13:05 Jibec

Ok, it took me some times, the verbose output doesn't help much. When it doesn't work, it doesn't work ;) Having some hind like: "reference folder not found", "l10n folder not found" would help!

can you please tell me how to interpret the results?

fr:
missing          16
missing_w        87
obsolete         78
changed        1615
changed_w      6267
unchanged       114
unchanged_w     132
keys            275
92% of entries changed

And I tried, but I couldn't get rid of the "locales" variable. I wanted to pass it as a parameter but didn't succeed.

basepath = "."

[env]
    l = "{locale}/"

[[paths]]
    reference = "devtools/client/locales/en-US/**"
    l10n = "{l}devtools/client/**"

locales = [
    "fr",
]

Jibec avatar May 21 '19 20:05 Jibec

kind reminder, can you please tell me how to interpret the results? and how to get rid of the "locales" list?

here is my understanding:

  • missing 16 <= untranslated source messages?
  • missing_w 87 <= untranslated source words?
  • obsolete 78 <= is it also counted in changed? is the unit messages?
  • changed 1615 <= translated source messages?
  • changed_w 6267 <= translated words? Is it the number of source words translated or the number of words in the translated content?
  • unchanged 114 <= to be counted as translated or untranslated messages?
  • unchanged_w 132 <= to be counted as translated or untranslated words?
  • keys 275 <= what is it?

Jibec avatar Jul 26 '19 07:07 Jibec