camptocamp / c2cgeoportal

c2cgeoportal application
http://geomapfish.org
Other
64 stars 46 forks source link

Translations file automatically updated on build #3308

Closed rbovard closed 6 years ago

rbovard commented 6 years ago

After every build, the file <package>-client.po is updated even if no transalations were edited.

$ make -f instance_dev.mk build
rm -f <package>/locale/<package>-client.pot # Because of WindowsError, thus only problematic on Windows
.build/venv/bin/pot-create --config lingua-client.cfg --output <package>/locale/<package>-client.pot <package>/templates/mobile.html <package>/static-ngeo/js/<package>module.js <package>/static-ngeo/js/mobile.js   <package>/static-ngeo/components/contextualdata/contextualdata.html .build/config.yaml development.ini
No handlers could be found for logger "c2cgeoportal.pyramid_"
Get WMS GetCapabilities for URL: http://localhost/dev/mapserv
Get WFS DescribeFeatureType for URL: http://localhost/dev/mapserv?VERSION=1.1.0&REQUEST=DescribeFeatureType&SERVICE=WFS
# removes the always changed date line
sed -i '/^"POT-Creation-Date: /d' <package>/locale/<package>-client.pot
sed -i '/^"PO-Revision-Date: /d' <package>/locale/<package>-client.pot
chmod go+r <package>/locale/<package>-client.pot
mkdir -p <package>/locale/fr/LC_MESSAGES/
[ -f <package>/locale/fr/LC_MESSAGES/<package>-client.po ] || msginit --no-translator --input=<package>/locale/<package>-client.pot --output-file=<package>/locale/fr/LC_MESSAGES/<package>-client.po -l fr
touch --no-create <package>/locale/fr/LC_MESSAGES/<package>-client.po
msgmerge --backup=none --update --sort-output --no-location <package>/locale/fr/LC_MESSAGES/<package>-client.po <package>/locale/<package>-client.pot
.................................................................................................................... done.
mkdir -p <package>/static-ngeo/build/
node node_modules/.bin/compile-catalog \
        .build/locale/fr/LC_MESSAGES/gmf.po \
        .build/locale/fr/LC_MESSAGES/ngeo.po \
        <package>/locale/fr/LC_MESSAGES/<package>-client.po > <package>/static-ngeo/build/fr.json
msgfmt -o <package>/locale/fr/LC_MESSAGES/<package>-client.mo <package>/locale/fr/LC_MESSAGES/<package>-client.po
touch --no-create <package>/locale/fr/LC_MESSAGES/<package>-client.mo
rm -f <package>/locale/<package>-server.pot # Because of WindowsError, thus only problematic on Windows
.build/venv/bin/pot-create --keyword _ --config lingua-server.cfg --output <package>/locale/<package>-server.pot <package>/models.py <package>/templates/desktop.html <package>/templates/mobile.html <package>/templates/api/xapihelp.html <package>/templates/api/apihelp.html <package>/templates/api/apihelp_old.html || true
/var/www/vhosts/<package>-geoportail/private/dev/.build/venv/local/lib/python2.7/site-packages/lingua/extract.py:330: UnicodeWarning: Python extractor called with bytes input. Please update your plugin to submit unicode instead.
  for message in extractor(real_filename, options):
No translatable strings found, aborting
# removes the always changed date line
[ ! -f <package>/locale/<package>-server.pot ] || sed -i '/^"POT-Creation-Date: /d' <package>/locale/<package>-server.pot
[ ! -f <package>/locale/<package>-server.pot ] || sed -i '/^"PO-Revision-Date: /d' <package>/locale/<package>-server.pot
[ ! -f <package>/locale/<package>-server.pot ] || chmod go+r <package>/locale/<package>-server.pot
mkdir -p <package>/locale/fr/LC_MESSAGES/
[ -f <package>/locale/fr/LC_MESSAGES/<package>-server.po ] || msginit --no-translator --input=<package>/locale/<package>-server.pot --output-file=<package>/locale/fr/LC_MESSAGES/<package>-server.po -l fr
touch --no-create <package>/locale/fr/LC_MESSAGES/<package>-server.po
[ ! -f <package>/locale/<package>-server.pot ] || msgmerge --backup=none --update --sort-output --no-location <package>/locale/fr/LC_MESSAGES/<package>-server.po <package>/locale/<package>-server.pot
msgfmt -o <package>/locale/fr/LC_MESSAGES/<package>-server.mo <package>/locale/fr/LC_MESSAGES/<package>-server.po
touch --no-create <package>/locale/fr/LC_MESSAGES/<package>-server.mo
sudo /usr/sbin/apache2ctl graceful
touch .build/apache.timestamp
.build/venv/bin/generate_controller --capabilities
$ git status
        modified:   <package>/locale/fr/LC_MESSAGES/<package>-client.po

If I do a l10nv1tov2

$ .build/venv/bin/l10nv1tov2 fr <package>/static/js/Proj/Lang/fr.js <package>/locale/fr/LC_MESSAGES/<package>-client.po

The file is now correct (no changes)

$ git status
nothing to commit, working directory clean

It reminds me https://github.com/camptocamp/c2cgeoportal/issues/2377

sbrunner commented 6 years ago

You can add in your file <project>.mk after the incluse CONST_Makefile:

$(PACKAGE)/locale/%/LC_MESSAGES/$(PACKAGE)-$(L10N_CLIENT_POSTFIX).po: $(PACKAGE)/static/js/Proj/Lang/%.js
    .build/venv/bin/l10nv1tov2 $* $< $@

Just for explain:

rbovard commented 6 years ago

Thanks @sbrunner but it doesn't change the situation.

With this modification, after a build I still have the unwanted changes in my <package>-client.po and I need to redo manually a l10nv1tov2.

And if I do a change in <package>/static/js/Proj/Lang/fr.js and a build after that, the change is not repercuted in the <package>-client.po, I also need to redo manually a l10nv1tov2 to have them.

rbovard commented 6 years ago

The unwanted changes in <package>-client.po contain a lot of #~ msgid and +#, fuzzy.

sbrunner commented 6 years ago

New solution by adding the following rules for the french:

$(PACKAGE)/locale/fr/LC_MESSAGES/$(PACKAGE)-$(L10N_CLIENT_POSTFIX).po: $(PACKAGE)/static/js/Proj/Lang/fr.js
       .build/venv/bin/l10nv1tov2 fr $< $@

$(PACKAGE)/locale/nyon-client.pot:
       @echo nothing to do for $@
rbovard commented 6 years ago

Thanks it seems better, I have no more those unwanted changes after rebuilds.

I don't know if it's related, but I have this warning:

.build/venv/bin/pot-create --keyword _ --config lingua-server.cfg --output nyon/locale/nyon-server.pot nyon/models.py nyon/templates/desktop.html nyon/templates/mobile.html nyon/templates/api/xapihelp.html nyon/templates/api/apihelp.html nyon/templates/api/apihelp_old.html || true
.build/venv/local/lib/python2.7/site-packages/lingua/extract.py:330: UnicodeWarning: Python extractor called with bytes input. Please update your plugin to submit unicode instead.
  for message in extractor(real_filename, options):
No translatable strings found, aborting
# removes the always changed date line
[ ! -f nyon/locale/nyon-server.pot ] || sed -i '/^"POT-Creation-Date: /d' nyon/locale/nyon-server.pot
[ ! -f nyon/locale/nyon-server.pot ] || sed -i '/^"PO-Revision-Date: /d' nyon/locale/nyon-server.pot
[ ! -f nyon/locale/nyon-server.pot ] || chmod go+r nyon/locale/nyon-server.pot

If it's ok for you, you can close this issue.

sbrunner commented 6 years ago

Thanks for the feedback :-)

rbovard commented 6 years ago

Mmmh I think there is a side effect because after a make clean (in v2.2.1), I got this error:

nyon.mk:34: warning: overriding recipe for target 'nyon/locale/nyon-client.pot'
CONST_Makefile:725: warning: ignoring old recipe for target 'nyon/locale/nyon-client.pot'
Nothing to do for nyon/locale/nyon-client.pot
mkdir -p nyon/locale/fr/LC_MESSAGES/
[ -f nyon/locale/fr/LC_MESSAGES/nyon-client.po ] || msginit --no-translator --input=nyon/locale/nyon-client.pot --output-file=nyon/locale/fr/LC_MESSAGES/nyon-client.po -l fr
touch --no-create nyon/locale/fr/LC_MESSAGES/nyon-client.po
msgmerge --backup=none --update --sort-output --no-location nyon/locale/fr/LC_MESSAGES/nyon-client.po nyon/locale/nyon-client.pot
msgmerge: error while opening "nyon/locale/nyon-client.pot" for reading: No such file or directory
CONST_Makefile:743: recipe for target 'nyon/locale/fr/LC_MESSAGES/nyon-client.po' failed
make: *** [nyon/locale/fr/LC_MESSAGES/nyon-client.po] Error 1

@sbrunner Could you please reopen it?

rbovard commented 6 years ago

@ochriste ?

ochriste commented 6 years ago

sorry, I reopened this by error

rbovard commented 6 years ago

In fact it should be reopened since the fix of @sbrunner doesn't work after a build after a clean all.

I was wondering why you closed it.

ochriste commented 6 years ago

oh, because it was already closed, so I just put it back to the state it was. but we can reopen it if the issue is still not solved, sorry about that.

sbrunner commented 6 years ago

@rbovard I'm not able to reproduce it...

@@ -26,3 +26,9 @@ DEPLOY_BRANCH_BASE_URL ?= $(VISIBLE_PROTOCOL)://$(VISIBLE_HOST) DEPLOY_BRANCH_MAKEFILE ?= nyon.mk

include CONST_Makefile + +$(PACKAGE)/locale/fr/LC_MESSAGES/$(PACKAGE)-$(L10N_CLIENT_POSTFIX).po: $(PACKAGE)/static/js/Proj/Lang/fr.js

rbovard commented 6 years ago

@sbrunner On branch 2.2?

git clone git@github.com:camptocamp/nyon_c2cgeoportal.git
cd nyon_c2cgeoportal
git checkout -b v22 origin/v22
(get secure.mk)
make -f instance_dev_$USER.mk build
git status
On branch v22
Your branch is up-to-date with 'origin/v22'.
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   nyon/locale/fr/LC_MESSAGES/nyon-client.po

The diff is the same type as I sent you by email (a lot of fuzzy and #~)...

sbrunner commented 6 years ago

I dontn't see any trace of the workaround then it can work... (or where is it?)

rbovard commented 6 years ago

Be aware of this side effect when fixing this issue.

rbovard commented 6 years ago

Effectively, I forgot to use it...

It's the case now, after a cleanall and a build, I still have those unwanted changes...

sbrunner commented 6 years ago

No more present on 2.3, closing