Discussion:
Non-gettexted string detection tools?
J.D. Grimes
2013-09-24 21:59:48 UTC
Permalink
Hello hackers,

I'm wondering if there are any tools out there that automatically parse a plugin/theme file and detect any strings that haven't been made translatable. I've looked at the i18n tools (http://core.trac.wordpress.org/browser/trunk/tools/i18n/) but none of those seem to do this exactly (am I wrong?). Does anyone know if something like this exists?

Thanks,

J.D.
Marko Heijnen
2013-09-24 22:07:59 UTC
Permalink
That is a really good question. As far as I know i18n tools only add a textdomain or create a pot file.
I do like the idea but it will lead to false detection of strings that don't need to be translated.

Marko
Post by J.D. Grimes
Hello hackers,
I'm wondering if there are any tools out there that automatically parse a plugin/theme file and detect any strings that haven't been made translatable. I've looked at the i18n tools (http://core.trac.wordpress.org/browser/trunk/tools/i18n/) but none of those seem to do this exactly (am I wrong?). Does anyone know if something like this exists?
Thanks,
J.D.
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
J.D. Grimes
2013-09-24 22:11:02 UTC
Permalink
Yeah, I know it will lead to false detection, but it could be made to cache the false positives so that after the first run it would ignore them…

J.D.
Post by Marko Heijnen
That is a really good question. As far as I know i18n tools only add a textdomain or create a pot file.
I do like the idea but it will lead to false detection of strings that don't need to be translated.
Marko
Shea Bunge
2013-09-24 23:30:05 UTC
Permalink
You can try the Pig Latin <http://wordpress.org/plugins/piglatin/> plugin
that displays all translatable strings as Pig
Latin<http://en.wikipedia.org/wiki/Pig_Latin>.
This way, all untranslated strings stick out.
Post by J.D. Grimes
Yeah, I know it will lead to false detection, but it could be made to
cache the false positives so that after the first run it would ignore them…
J.D.
Post by Marko Heijnen
That is a really good question. As far as I know i18n tools only add a
textdomain or create a pot file.
Post by Marko Heijnen
I do like the idea but it will lead to false detection of strings that
don't need to be translated.
Post by Marko Heijnen
Marko
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
--
Regards,

Shea Bunge
http://bungeshea.com
Andrew Nacin
2013-09-25 00:32:38 UTC
Permalink
Post by Shea Bunge
You can try the Pig Latin <http://wordpress.org/plugins/piglatin/> plugin
that displays all translatable strings as Pig
Latin<http://en.wikipedia.org/wiki/Pig_Latin>.
This way, all untranslated strings stick out.
Others might laugh, but this is pretty standard practice.
Others prefer an encheferizer.
http://en.wikipedia.org/wiki/Swedish_Chef#Computer_translations

For something more jarring, try:

$empty_string = function() { return ''; };
foreach ( array( 'gettext', 'ngettext' ) as $filter ) {
add_filter( $filter, $empty_string );
add_filter( $filter . '_with_context', $empty_string );
}
Nikola Nikolov
2013-09-25 07:21:25 UTC
Permalink
What I feel like you're aiming for is parsing php files and finding any
un-translated strings in there.

The plugin that I regularly use in order to edit/create .po/.mo files -
http://wordpress.org/plugins/codestyling-localization/ - does something
similar, except for it only looks for translated strings. My recommendation
would be to take a look at it's code(more specifically the
"/includes/class.parser.php" file -
http://plugins.svn.wordpress.org/codestyling-localization/trunk/includes/class.parser.php
)
and try to adjust it to ignore any strings that have already been
translated and collect the ones that haven't.

I think that code is a good place to start and you can probably do that
with just a simple file in the beginning and then move on to series of
files in a plugin/theme.

Good luck with that and I'd like to know when you get it done :)

Nikola
Post by J.D. Grimes
Post by Shea Bunge
You can try the Pig Latin <http://wordpress.org/plugins/piglatin/>
plugin
Post by Shea Bunge
that displays all translatable strings as Pig
Latin<http://en.wikipedia.org/wiki/Pig_Latin>.
This way, all untranslated strings stick out.
Others might laugh, but this is pretty standard practice.
Others prefer an encheferizer.
http://en.wikipedia.org/wiki/Swedish_Chef#Computer_translations
$empty_string = function() { return ''; };
foreach ( array( 'gettext', 'ngettext' ) as $filter ) {
add_filter( $filter, $empty_string );
add_filter( $filter . '_with_context', $empty_string );
}
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
J.D. Grimes
2013-09-25 14:06:59 UTC
Permalink
Thank you all for the links!

I think I'm going to follow Nikola's idea. And I'll be sure to share the results back here when I'm done.

Thanks,

J.D.
Post by Nikola Nikolov
What I feel like you're aiming for is parsing php files and finding any
un-translated strings in there.
The plugin that I regularly use in order to edit/create .po/.mo files -
http://wordpress.org/plugins/codestyling-localization/ - does something
similar, except for it only looks for translated strings. My recommendation
would be to take a look at it's code(more specifically the
"/includes/class.parser.php" file -
http://plugins.svn.wordpress.org/codestyling-localization/trunk/includes/class.parser.php
)
and try to adjust it to ignore any strings that have already been
translated and collect the ones that haven't.
I think that code is a good place to start and you can probably do that
with just a simple file in the beginning and then move on to series of
files in a plugin/theme.
Good luck with that and I'd like to know when you get it done :)
Nikola
Post by J.D. Grimes
Post by Shea Bunge
You can try the Pig Latin <http://wordpress.org/plugins/piglatin/>
plugin
Post by Shea Bunge
that displays all translatable strings as Pig
Latin<http://en.wikipedia.org/wiki/Pig_Latin>.
This way, all untranslated strings stick out.
Others might laugh, but this is pretty standard practice.
Others prefer an encheferizer.
http://en.wikipedia.org/wiki/Swedish_Chef#Computer_translations
$empty_string = function() { return ''; };
foreach ( array( 'gettext', 'ngettext' ) as $filter ) {
add_filter( $filter, $empty_string );
add_filter( $filter . '_with_context', $empty_string );
}
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
J.D. Grimes
2013-11-12 17:02:46 UTC
Permalink
I’ve been working on this in my spare time, and I finally have something to show for it: https://github.com/JDGrimes/wp-l10n-validator

It probably still has some bugs in it and there are still some improvements I’d like to make, but you’re welcome to try it out. I’d be interested in any feedback.

-J.D.
Post by J.D. Grimes
Thank you all for the links!
I think I'm going to follow Nikola's idea. And I'll be sure to share the results back here when I'm done.
Thanks,
J.D.
Post by Nikola Nikolov
What I feel like you're aiming for is parsing php files and finding any
un-translated strings in there.
The plugin that I regularly use in order to edit/create .po/.mo files -
http://wordpress.org/plugins/codestyling-localization/ - does something
similar, except for it only looks for translated strings. My recommendation
would be to take a look at it's code(more specifically the
"/includes/class.parser.php" file -
http://plugins.svn.wordpress.org/codestyling-localization/trunk/includes/class.parser.php
)
and try to adjust it to ignore any strings that have already been
translated and collect the ones that haven't.
I think that code is a good place to start and you can probably do that
with just a simple file in the beginning and then move on to series of
files in a plugin/theme.
Good luck with that and I'd like to know when you get it done :)
Nikola
Post by J.D. Grimes
Post by Shea Bunge
You can try the Pig Latin <http://wordpress.org/plugins/piglatin/>
plugin
Post by Shea Bunge
that displays all translatable strings as Pig
Latin<http://en.wikipedia.org/wiki/Pig_Latin>.
This way, all untranslated strings stick out.
Others might laugh, but this is pretty standard practice.
Others prefer an encheferizer.
http://en.wikipedia.org/wiki/Swedish_Chef#Computer_translations
$empty_string = function() { return ''; };
foreach ( array( 'gettext', 'ngettext' ) as $filter ) {
add_filter( $filter, $empty_string );
add_filter( $filter . '_with_context', $empty_string );
}
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
Loading...