PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, September 1, 2022

[FIXED] How to translate CakePHP's core domain strings with POEdit?

 September 01, 2022     cakephp, cakephp-2.0, poedit     No comments   

Issue

It's not the first time I set up POEdit to work with CakePHP, but it's the first time I need to translate core strings on a site. Specifically, I need to translate the strings on TimeHelper's timeAgoInWords() function. The problem is that all strings in there are encapsulated in __d() and __dn() functions (instead of regular __(), __n(), etc), which use the translation domain name as the first parameter, instead of the translatable string. So if I tell POEdit to include __d and __dn as keywords in the catalog, it thinks "cake" and "cake_dev" are translatable strings.

What's the best way to translate CakePHP's core strings that on the "cake" domain?

You can see the code of timeAgoInWords here.

Thanks.


Solution

OK, I found the answer hidden here on SO. A combination of this and this other question:

  • First, I added the __d keyword in the form of __d:2 so it took the second parameter instead of the first.
  • I also added a __dn:2,3 keyword.
  • Then I configured the plural forms (nplurals=2; plural=n != 1;) on POEdit in order to make the previous keyword work.

All worked like a charm.

I hope this helps somebody else.



Answered By - luchomolina
Answer Checked By - Terry (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing