Cakephp: Issues when loading MO/PO translation files

Created on 30 Jul 2017  路  3Comments  路  Source: cakephp/cakephp

This is a (multiple allowed):

  • [x] bug
  • [ ] enhancement
  • [ ] feature-discussion (RFC)

  • CakePHP Version: 3.4.11

I have some projects where I use empty translation files. My PO files my have some possible translations flagged fuzzy while the compliled MO files will be empty.

CakePHP loads the MO files then checks they're not empty or the PO file is loaded instead. This has 2 immediate consequences:

  • it uses quite some memory due to lots of arrays used for empty translations.
  • fuzzy translations become visible.

All of this wouldn't happen if there was at least one translation in the MO file. One translation up and the behavior changes significantly.

Is this the intended way to do it? If not I'm willing to work on it.

I would propose:

  • Not ignoring empty MO files. Maybe check timestamps with PO files instead.
  • Don't load empty translations in the PO file parser.
  • Honoring the fuzzy flag in PO files so it's the same than loading corresponding MO files.
defect i18n

Most helpful comment

I'll make a PR soon.

All 3 comments

It makes sense to not load the po, regardless of the contents of the mo. Would you like to make that change? I really it should just check whether or not the mo file exists, if it does then it should not load the po at all

I'll make a PR soon.

Closing as a pull request is open now.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nrother picture nrother  路  3Comments

gtrias picture gtrias  路  4Comments

inoas picture inoas  路  3Comments

Code-Working picture Code-Working  路  3Comments

cleptric picture cleptric  路  3Comments