Create a POT file using Poedit

I am desperate to create a directory (.In) for my new application in php. 1) I created the file "trans.php", where I put all the values ​​that need to be translated

For example, here is my file:

<?php echo _e('SORTIR LA NUIT'); ?> 

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

paths configuration in poedit

3) When I click "update", I get 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?

Respectfully,

+6
source share
3 answers

you should use _ instead of _e , for example

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

By the way, _e is a function from the Wordpress engine, it does the same, but it is not a predefined PHP function.

+9
source

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

If did not find any files in scanned directories allowed, POEdit will probably find 0 messages anyway. This is because, by default, POEdit does not support _e as a keyword. To solve this problem, simply add " _e " to the keyword list (in Catalog > Settings > Keywords ).

+17
source

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

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

this was after I tried to add this: __ () and this: _e () to the Keywords, but it failed to solve the problem ... so for me the solution is to change it to _ () for po edit and after it takes all the words from the code (wp theme or plugin), I changed all this to __ ().

+1
source

Source: https://habr.com/ru/post/907388/


All Articles