Create POT file with Poedit
Asked Answered
S

3

7

I'm trying desperately to create a catalog (. In) for my new application in php. 1) I created a file "trans.php" where I put all the values ​​to be translated

For example, here is my file:

<?php 

echo _e('SORTIR LA NUIT');

?>

2) I open Poedit, in the "Paths" here's what I entered (see photo) Then I save the same location of my file "php".

paths configuration in Poedit

3) When I click "update", I have the following errors:

12:25:43: No files found in: /Users/aweaoftheworld/Desktop/test
12:25:43: Poedit did not find any files in scanned directories.
12:25:43: Entries in the catalog are probably incorrect.
12:25:43: Updating the catalog failed. Click on 'More>>' for details.

Can you help me?

Sincerely,

Somehow answered 1/2, 2012 at 11:29 Comment(1)
_() is an alias for gettext() php.net/manual/function.gettext.phpBaeza
I
9

you should use _ instead of _e, for example

<?php echo _("hi there i am gettext library") ?>

by the way, _e function is from Wordpress engine, it doing same but it's not PHP predefined function.

Intisar answered 1/2, 2012 at 13:27 Comment(0)
C
17

Make sure the path(s) defined in POEdit (Catalog > Settings > Paths) point to the folder that contains your PHP files. This should solve the problem of POEdit not finding the files.

If the did not find any files in scanned directories is resolved, POEdit will probably still find 0 messages. This is because by default POEdit doesn't support _e as a keyword. To resolve this problem, simply add "_e" to the list of keywords (in Catalog > Settings > Keywords).

Corroborant answered 16/7, 2012 at 11:2 Comment(1)
I was using _() and the Paths were correct, but POEdit 1.4.6 could not parse anything (same error), while manually using xgettext worked fine. In my case upgrading to 1.5.4 solved the problem (OS: Ubuntu 12.04.4).Disrepute
I
9

you should use _ instead of _e, for example

<?php echo _("hi there i am gettext library") ?>

by the way, _e function is from Wordpress engine, it doing same but it's not PHP predefined function.

Intisar answered 1/2, 2012 at 13:27 Comment(0)
L
1

Only if i use _() instead of _e() or instead of __() - poedit can find my strings - but, in wordpress i get this error:

Warning: _() expects exactly 1 parameter, 2 given in C:\xampp\htdocs\xxx.php on line xxx

it was after i try to add this: __() and this: _e() to "Keywords" but its did'nt solve the problem... so for me the solution is to change it to _() for po edit and after it take all the words from code(wp theme or plugin) i change it all to __().

Loireatlantique answered 23/10, 2014 at 9:53 Comment(3)
That's just silly. See the answer right above yours for what you're doing wrong -- you need to add this non-default keyword.Haffner
in line 4 i wrote: it was after i try to add this: __() and this: _e() to "Keywords" but its did'nt solve the problem...Loireatlantique
Then you either use _e() incorrectly in your code or didn't in fact add it to Keywords by some accident (perhaps misspelling it) or didn't refresh the catalog. But the fact is that the non-default _e keyword is recognized perfectly fine by Poedit and xgettext and whatever problem you're having, it's not with Poedit's inability to see _e().Haffner

© 2022 - 2024 — McMap. All rights reserved.