Comments (10)
This would mean we need to work with the AST of PHP / JavaScript file.
#26 already uses a JS AST parser.
https://github.com/nikic/PHP-Parser is a popular one for PHP. It would make sense to use that for the make-pot
task as well, however it requires PHP 7.
from i18n-command.
After looking at #28 I think this command would need:
- An
--only-missing
option to only add the domain where it's missing - A way to only replace a specific domain with a new one, in case the source folder contains strings with multiple text domains.
from i18n-command.
@swissspidy is there any update on this ?
from i18n-command.
@swissspidy how can i use add-text-domain
cmd in cli to append text domains to wp functions inside my plugin / theme ( __()
)
from i18n-command.
@varunsridharan No update I am afraid. add-text-domain
does currently not exist.
However, you can achieve this using the WordPress-Coding-Standards PHPCS configuration as long as you set your text domain accordingly.
I think that is probably the best solution for this specific task.
Once you've configured PHPCS with the WordPress coding standards, you can use phpcbf to automatically fix any i18n functions that don't use your required text domain.
from i18n-command.
@swissspidy thanks for your faster reply. well i work on quite a lot of projects and i use common rules-set.xl in phpstorm and i dont think that will work for me :-(
from i18n-command.
I think that should still work. You don't have to include all of WPCS in your ruleset, just the text domain sniff is enough. Then, you can even auto-fix things directly in PHPStorm.
from i18n-command.
Based on my testing i can say that PHPStorm dose not support multiple ruleset in a single project.
from i18n-command.
@swissspidy thanks for your time. i was not able to get this done using PHPStrom / Rule set not sure why may be i was doing something wrong.
and i created a simple composer package which dose this job
Old Link : https://github.com/varunsridharan/wp-cli
New Link : https://github.com/varunsridharan/wp-cli-textdomain
from i18n-command.
Closing for now as this seems better suited for a tool like PHPCS, as mentioned in the discussion above. https://github.com/varunsridharan/wp-cli-textdomain exists for people who want a dedicated command/script.
from i18n-command.
Related Issues (20)
- Undefined method WP_CLI\I18n\MakePotCommand::get_file_data_from_string HOT 1
- PHP i18n functions prefixed with a slash are ignored HOT 11
- i18n make-pot database required? HOT 5
- make-pot failing to parse specific JavaScript code HOT 8
- Missing file name and line numbers in POT file HOT 8
- PHP 8.2 - PHP Deprecated: Use of "static" in callables is deprecated in ...i18n-command/src/IterableCodeExtractor.php on line 245/246
- update-po: Doesn't preserve / create X-Domain header of .pot file HOT 3
- sokirka HOT 1
- PHP Warning: mkdir(): Read-only file system in MakePotCommand.php on line 376 HOT 6
- `make-mo`: Add option to specify filename HOT 8
- Add tests verifying generated translation files work as intended
- PHP Warning: foreach() argument must be of type array|object, HOT 3
- Consider adding file reference for strings extracted from file headers
- Document example of how to format the --headers parameter in the `i18n make-pot` command HOT 1
- Are file references for plugin/theme headers supposed to be absolute paths? HOT 1
- wp i18n make-php - Expectations HOT 2
- wp i18n make-pot: Support PHP8 named parameters HOT 1
- Author URI of the plugin translation string in generated POT file HOT 3
- Issues parsing PO files without empty lines HOT 15
- make-php - Make output file content pretty HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from i18n-command.