Hi, How to extract string from .volt files ? With poedit or this one https://www.icanlocalize.com/tools/php%5scanner don't work.. the format of string used is:
{{ t._('My phrase') }}
thanks
|
Feb '20 |
12 |
1169 |
0 |
Hi, How to extract string from .volt files ? With poedit or this one https://www.icanlocalize.com/tools/php%5scanner don't work.. the format of string used is:
{{ t._('My phrase') }}
thanks
Can you get more information about the problem? In what sense and why does "extract"?
If you want to create the *.po localization-file in your project, you should move all of strings with the text in this file and use the translate component in the .volt like this.
{{ t._('TheConstantForTranslation') }}
You can make it manually. In my opinion, it's will be easier and faster then searching the automatic method. Good luck!
Hi, Is not ideal to create manually the .po files for large project. Is preferable and good practice to extract phrase directly from files, as poedit offer this: https://www.tiikoni.com/tis/view/?id=1413717
I think that this is the more faster and easier way than manually. Otherwise is like that you need to do double work.
At the moment the only workaround that I found is to extract from cached files.
I found also this Twig extractor: https://github.com/umpirsky/Twig-Gettext-Extractor, I need to test using volt, maybe just adding different extension can work.
I guess if someone had already solve this problem by preparing something custom for volt.
Thanks!
Thanks for this tip, but seem that don't help. Do you tested already? The parser of po edit search for php tag open (<?php) and php tag close (</php>) This is error message:
Sat May 21 12:50:44 2016: /Applications/Poedit.app/Contents/PlugIns/GettextTools.bundle/Contents/MacOS/bin/xgettext: cannot read view.volt: Start tag expected, '<' not found
Sat May 21 12:50:44 2016: /Applications/Poedit.app/Contents/PlugIns/GettextTools.bundle/Contents/MacOS/bin/xgettext: cannot read view.volt: Start tag expected, '<' not found
Sat May 21 12:50:44 2016: /Applications/Poedit.app/Contents/PlugIns/GettextTools.bundle/Contents/MacOS/bin/xgettext: cannot read view.volt: Start tag expected, '<' not found
Sat May 21 12:50:44 2016: /Applications/Poedit.app/Contents/PlugIns/GettextTools.bundle/Contents/MacOS/bin/xgettext: warning: file 'view.volt' extension 'volt' is unknown; will try C
Sat May 21 12:50:44 2016: /Applications/Poedit.app/Contents/PlugIns/GettextTools.bundle/Contents/MacOS/bin/xgettext: cannot read view.volt: Start tag expected, '<' not found
I think you mean that poedit is not parsing .volt files? If yes, you can edit poedits settings.
- Open poedit
- Edit -> Settings
- Switch to Parser Tab
- Select PHP and click on edit
- Add *.volt to the list
Try a different Parser like C++
Thanks for this tip, but seem that don't help. Do you tested already? The parser of po edit search for php tag open (<?php) and php tag close (</php>) This is error message:
Sat May 21 12:50:44 2016: /Applications/Poedit.app/Contents/PlugIns/GettextTools.bundle/Contents/MacOS/bin/xgettext: cannot read view.volt: Start tag expected, '<' not found
Sat May 21 12:50:44 2016: /Applications/Poedit.app/Contents/PlugIns/GettextTools.bundle/Contents/MacOS/bin/xgettext: cannot read view.volt: Start tag expected, '<' not found
Sat May 21 12:50:44 2016: /Applications/Poedit.app/Contents/PlugIns/GettextTools.bundle/Contents/MacOS/bin/xgettext: cannot read view.volt: Start tag expected, '<' not found
Sat May 21 12:50:44 2016: /Applications/Poedit.app/Contents/PlugIns/GettextTools.bundle/Contents/MacOS/bin/xgettext: warning: file 'view.volt' extension 'volt' is unknown; will try C
Sat May 21 12:50:44 2016: /Applications/Poedit.app/Contents/PlugIns/GettextTools.bundle/Contents/MacOS/bin/xgettext: cannot read view.volt: Start tag expected, '<' not found
I think you mean that poedit is not parsing .volt files? If yes, you can edit poedits settings.
- Open poedit
- Edit -> Settings
- Switch to Parser Tab
- Select PHP and click on edit
- Add *.volt to the list
I use this bash script to parse translations:
find . -path './vendor' -prune -o -printf '%p\n' | sort -n | grep '\.php$' | xargs xgettext --from-code=UTF-8 --default-domain=default -o ./locale/template.pot
The idea behind it is that the Volt engine generates php files for final use, so I get the phrases from there, not the .volt files. You would have to have all pages visited ofc, or a script that compiles all volt files to the cached php.
Try a different Parser like C++
Can you please tell me more how to do this? Thanks
Thanks for your suggestion, but don't work. This is just a few of similar error messages:
Wed May 25 19:18:07 2016: cover.volt:2: warning: unterminated character constant
Wed May 25 19:18:08 2016: /Applications/Poedit.app/Contents/PlugIns/GettextTools.bundle/Contents/MacOS/bin/xgettext: cannot read login.volt: Start tag expected, '<' not found
Wed May 25 19:18:08 2016: /Applications/Poedit.app/Contents/PlugIns/GettextTools.bundle/Contents/MacOS/bin/xgettext: warning: file 'register.volt' extension 'volt' is unknown; will try C
Open poedit Edit -> Settings Switch to Parser Tab Select C++ and click on edit Add *.volt to the list
Yes from cache files work fine, but I would like to extract from volt file.
I use this bash script to parse translations:
find . -path './vendor' -prune -o -printf '%p\n' | sort -n | grep '\.php$' | xargs xgettext --from-code=UTF-8 --default-domain=default -o ./locale/template.pot
The idea behind it is that the Volt engine generates php files for final use, so I get the phrases from there, not the .volt files. You would have to have all pages visited ofc, or a script that compiles all volt files to the cached php.
This Works:
After this i could parse volt files
Hi, thanks for suggestion, but I have already try that. I try again now and still not working, this is a few error msg:
Thu May 26 10:06:55 2016: page.volt:2: warning: unterminated character constant
Thu May 26 10:06:56 2016: posts.volt:83: warning: unterminated string
Thu May 26 10:06:56 2016: /Applications/Poedit.app/Contents/PlugIns/GettextTools.bundle/Contents/MacOS/bin/xgettext: Non-ASCII character at search.volt:83.
Thu May 26 10:06:56 2016: Please specify the source encoding through --from-code or through a comment
Thu May 26 10:06:56 2016: as specified in https://www.python.org/peps/pep-0263.html.
Thu May 26 10:06:56 2016:
Thu May 26 10:06:56 2016: Entries in the catalog are probably incorrect.
Thu May 26 10:06:56 2016: Updating the catalog failed. Click on 'Details >>' for details.
Just a note: point 4. Remove all parser
First of all I need to go to "Poedit > Preferences > Extractor" (maybe because I am using a mac is different?)
Second thing is that I don't delete existing extractor (what you call "parser").
Screenshot:
Yes, you are right, work fine after adding encoding. I get different error message, but seem that all phrase are extracted.
Big thanks!
The error only says you have to define the encoding of your catalog before you try to extract the strings.
Can you please tell me more how to do this? Thanks
Yes, you are right, work fine after adding encoding. I get different error message, but seem that all phrase are extracted.
Big thanks!
The error only says you have to define the encoding of your catalog before you try to extract the strings.
Thank you for replying me. What does Phalcon need to do to make Poedit extract {{ t._('') }}? the encoding is UTF-8
https://upload.cc/i1/2019/10/17/oSgDm1.png https://upload.cc/i1/2019/10/17/qmPsXI.png