#1081 Fetch weblate translations for all websites
Merged 2 years ago by kevin. Opened 2 years ago by darknao.
darknao/fedora-websites l10n_fix  into  master

file modified
+5 -2
@@ -27,7 +27,7 @@ 

  		fi   \

  	fi

  

- all:: $(LANGUAGES)

+ all:: en $(LANGUAGES)

  	cp static/robots.txt out/

  

  static:
@@ -44,6 +44,9 @@ 

  for me to get its name.. Please use a wise name."

  endif

  

+ po/en.po: pot

+ 	msginit -i $(POT_FILE) --no-translator -l en -o po/en.po

+ 

  data/templates/translations.html: po/LINGUAS

  	$(PYTHON) $(BUILDDIR)/construct-translations.py $(BUILDDIR)/translations.ini $^ $@

  
@@ -59,7 +62,7 @@ 

  	rm -rf $(TRANS_TMP)

  

  pullpos:

- 	git clone ssh://git@pagure.io/fedora-web/translations.git $(TRANS_TMP)

+ 	git clone https://pagure.io/fedora-web/translations.git $(TRANS_TMP)

  	cp -R $(TRANS_TMP)/$(TRANS_FOLDER)/*.po ./po/

  	cp -R $(TRANS_TMP)/$(TRANS_FOLDER)/LINGUAS ./po/

  	rm -rf $(TRANS_TMP)

@@ -1,5 +1,5 @@ 

  include ../Makefile.in

  

- $(LANGUAGES): % : | static po/%.mo data/templates/translations.html

+ en $(LANGUAGES): % : | static po/%.mo data/templates/translations.html

  	$(PYTHON) $(BUILDDIR)/build.py -o out -i data/content -l $@ -p po -b $(BASEPATH)

  

@@ -1,5 +1,5 @@ 

  include ../Makefile.in

  

- $(LANGUAGES): % : | static rss-cache po/%.mo data/templates/translations.html

+ en $(LANGUAGES): % : | static rss-cache po/%.mo data/templates/translations.html

  	$(PYTHON) $(BUILDDIR)/build.py -o out -i data/content -l $@ -p po -b $(BASEPATH)

  

@@ -1,5 +1,8 @@ 

  include ../Makefile.in

  

+ # retired

+ pullpos: ;

+ 

  $(LANGUAGES): % : | static po/%.mo data/templates/translations.html

  	$(PYTHON) $(BUILDDIR)/build.py -o out -i data/content -l $@ -p po -b $(BASEPATH)

  

@@ -1,5 +1,8 @@ 

  include ../Makefile.in

  

+ # no translation

+ pullpos: ;

+ 

  $(LANGUAGES): % : | static rss-cache po/%.mo data/templates/translations.html

  	$(PYTHON) $(BUILDDIR)/build.py -o out -i data/content -l $@ -p po -b $(BASEPATH)

  

file modified
+1 -1
@@ -1,7 +1,7 @@ 

  #!/usr/bin/python

  import sys

  

- languages = []

+ languages = [("en", "en"),]

  

  linguasfile = sys.argv[1]

  linguas = open(linguasfile)

@@ -1,6 +1,7 @@ 

  #!/bin/env python

  

  import ConfigParser, sys, os

+ import langtable

  

  '''

  This script takes the contents of the website-specific LINGUAS file, constructs an options menu for the languages contained therein.
@@ -40,7 +41,8 @@ 

                  lang = lang.strip()

                  if lang and not lang.startswith('#') and not lang in banned:

                      #output.write('    <option value="' + lang + '" py:attrs="{\'selected\': lang == \'' + lang + '\' and \'selected\' or None}">' + language_map.get('Languages',lang) + '</option>\n')

-                     output.write(", '"+lang+"': '"+language_map.get('Languages',lang)+"'")

+                     #output.write(", '"+lang+"': '"+language_map.get('Languages',lang)+"'")

+                     output.write(", '"+lang+"': '"+langtable.language_name(languageId=lang).encode('utf-8')+"'")

          finally:

              linguas.close()

          output.write("""}

file modified
+1 -1
@@ -1,5 +1,5 @@ 

  include ../Makefile.in

  

- $(LANGUAGES): % : | static po/%.mo data/templates/translations.html

+ en $(LANGUAGES): % : | static po/%.mo data/templates/translations.html

  	$(PYTHON) $(BUILDDIR)/build.py -o out -i data/content -l $@ -p po -b $(BASEPATH)

  

@@ -1,5 +1,8 @@ 

  include ../Makefile.in

  

+ # retired? 

+ pullpos: ;

+ 

  $(LANGUAGES): % : | static rss-cache po/%.mo data/templates/translations.html

  	$(PYTHON) $(BUILDDIR)/build.py -o out -i data/content -l $@ -p po -b $(BASEPATH)

  

@@ -1,5 +1,8 @@ 

  include ../Makefile.in

  

+ # Not translated, yet

+ pullpos: ;

+ 

  $(LANGUAGES): % : | static rss-cache po/%.mo data/templates/translations.html

  	$(PYTHON) $(BUILDDIR)/build.py -o out -i data/content -l $@ -p po -b $(BASEPATH)

  

file modified
+3
@@ -1,5 +1,8 @@ 

  include ../Makefile.in

  

+ # moved (see fedora-web/websites)

+ pullpos: ;

+ 

  $(LANGUAGES): % : | static rss-cache po/%.mo data/templates/translations.html

  	$(PYTHON) $(BUILDDIR)/build.py -o out -i data/content -l $@ -p po -b $(BASEPATH)

  

@@ -1,5 +1,5 @@ 

  include ../Makefile.in

  

- $(LANGUAGES): % : | static rss-cache po/%.mo data/templates/translations.html

+ en $(LANGUAGES): % : | static rss-cache po/%.mo data/templates/translations.html

  	$(PYTHON) $(BUILDDIR)/build.py -o out -i data/content -l $@ -p po -b $(BASEPATH)

  

@@ -1,5 +1,5 @@ 

  include ../Makefile.in

  

- $(LANGUAGES): % : | static po/%.mo data/templates/translations.html

+ en $(LANGUAGES): % : | static po/%.mo data/templates/translations.html

  	$(PYTHON) $(BUILDDIR)/build.py -o out -i data/content -l $@ -p po -b $(BASEPATH)

  

@@ -1,8 +1,9 @@ 

  include ../Makefile.in

  

- $(LANGUAGES): % : | static rss-cache po/%.mo data/templates/translations.html

+ en $(LANGUAGES): % : | static rss-cache po/%.mo data/templates/translations.html

  	$(PYTHON) $(BUILDDIR)/build.py -o out -i data/content -l $@ -p po -b $(BASEPATH)

  

  rss-cache:

  	@echo Caching Magazine Feed...

- 	$(PYTHON) $(PWD)/build/magfeed.py -o out -s static -b $(BASEPATH) 

\ No newline at end of file

+ 	$(PYTHON) $(PWD)/build/magfeed.py -o out -s static -b $(BASEPATH)

+ 

related: https://pagure.io/fedora-infrastructure/issue/9996

This is a few fixups to get translation updated at build time.

The LINGUAS file from weblate does not contain the en language (which must be built anyway), so it's now hardcoded in the Makefile.
The pullpos function has been disabled on some websites that are either not present on weblate (yet) or simply retired.
I've also added the langtable library to build the language menu instead of using build.d/translations.ini, which is outdated.

Next step will be to update the build script to include the make pullpos command.

I have been discussing with @darknao regarding these changes.
I trust him to be able to fix localization issues with this change.

One single question: I'm using langtable in another project and did not had to embed xml files in the repo, this looks weird to me. May you explain the motivation?

Those files are used by the langtable library to get what I'm looking for, in this case, translated language name.
I actually don't need all of them, since I'm only using the language part of it. But unless we have some kind of space restriction in this repo, I tend to avoid stripping bits from third party

I can use the gz version though. Yep, let's do that

Well, afterthought, we don't need to embed this library. We should use the packaged version instead.

rebased onto 47d855a08f067bfe82be136fd4857ce6ba175bc6

2 years ago

rebased onto 9977de9

2 years ago

Pull-Request has been merged by kevin

2 years ago