i18n - Remove the lines numbers from message catalogs
Thousands of line changes like the ones below make it hard to see the actual changes:
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
modified: locale/en/manageiq.po
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
@ locale/en/manageiq.po:171 @ msgid " Add "
msgstr ""
#. TRANSLATORS: file: product/reports/650_Performance by Asset Type - Virtual Machines/150_All Departments with Performance.yaml
-#: ../config/yaml_strings.rb:7028
+#: ../config/yaml_strings.rb:7039
msgid " CPU - Peak Usage Rate Avg for Collected Intervals (%) (Max)"
msgstr ""
#. TRANSLATORS: file: product/reports/650_Performance by Asset Type - Virtual Machines/190_VM Resource Utilization.yaml
-#: ../config/yaml_strings.rb:7128
+#: ../config/yaml_strings.rb:7139
msgid " CPU - Usage (%)"
msgstr ""
@ locale/en/manageiq.po:189 @ msgid " Days"
msgstr ""
#. TRANSLATORS: file: product/reports/100_Configuration Management - Virtual Machines/009_VM Disk Usage.yaml
-#: ../config/yaml_strings.rb:5656
+#: ../config/yaml_strings.rb:5667
msgid " Derived Vm Allocated Disk Storage"
msgstr ""
#. TRANSLATORS: file: product/reports/650_Performance by Asset Type - Virtual Machines/190_VM Resource Utilization.yaml
-#: ../config/yaml_strings.rb:7134
+#: ../config/yaml_strings.rb:7145
msgid " Disk I/O - Avg (KBps)"
msgstr ""
... (thousands of similar line number changes)
@ locale/manageiq.pot:32596 @ msgstr ""
msgid "File is empty"
msgstr ""
+#: ../app/javascript/forms/mappers/validatorMapper.jsx:21
+msgid "File is too large, maximum allowed size is %s bytes. Current file has %s byte"
+msgid_plural "File is too large, maximum allowed size is %s bytes. Current file has %s bytes"
+msgstr[0] ""
+msgstr[1] ""
There is an option to a lot of the gettext tools to specify the type of location. By default it's filname:line but there is a file option we can try:
'--add-location=type'
Generate '#: filename:line' lines (default).
The optional type can be either 'full', 'file', or 'never'. If it is not given or 'full', it generates the lines with both file name and line number. If it is 'file', the line number part is omitted. If it is 'never', it completely suppresses the lines (same as --no-location).
ok, so it appears the --add-location=type option for specifying only the file is supported in gettext but not in ruby gettext or any of the ruby side code. I haven't tested with it but it looks like the only option would be to drop the location entirely, so no file:line at all and provide tools to ask gettext where a string comes from.
Is this something we can add to ruby gettext?
Well, from a quick glance, we'd have to add it to ruby gettext and ensure fast gettext, fast gettext i18n rails, and fast gettext i18n rails js supports a reference comment only being a filename. It's not as easy as I hoped but I can take a look some more.
I think there are few options:
-
Add support for add-location=file in the above libraries and ensure it works. This minimizes git churn but it's unclear how much work this is or if it will be accepted upstream in all repositories needing this change.
-
Commit only a location free version as pot/po and add some utilities to "retrieve" the annotated version. This also minimizes git churn but makes it more work and education to teach how to generate the annotated version. It's unclear if it's easy to do this from the po/pot with no reference locations as all of the existing mechanics look at the code on the filesystem which may be difficult to recreate after the fact with all of our git plugins.
-
Or, commit both the annotated "location" version and the "no location reference" version whenever we update the po/pot but only use the "no location reference" version for everything with the annotated only for translators/developers if they need to figure out the context of a translation string. Note, this increases the burden on git but we could also compress the files or whatever we need to make them less burdensome.
2.5. Continue to generate the file as is, but strip the line numbers in a post generate task. We may have to dedup some file references (where the same string is multiple times within the same file), but that doesn't have to be on the first pass if at all.
Ideally 1 is the best approach - might be worth looking into. @grosser, I believe, handles most of those gems and they are pretty responsive.
I would do 2.5 to get some immediate relief, followed by 1, which will technically be a no-op diff in the end if you do 2.5, aside from deleting the 2.5 code.
I think 2.5 is a simple sed, if you don't want to write it all in Ruby...This worked on my Mac (We can test of linux...I know -i works different on linux and shouldn't take the '' after it).
sed -i '' -r 's/^(#.+):[0-9]+$/\1/' locale/**/*.po
We can remove duplicate lines by just using uniq on the CLI
for f in $(ls locale/**/*.po); do uniq $f /tmp/po; mv -f /tmp/po $f; done