Git Product home page Git Product logo

mayukojpn / force-update-translations Goto Github PK

View Code? Open in Web Editor NEW
12.0 6.0 6.0 411 KB

Download WordPress theme/plugin translations and apply them to your site manually even their language pack haven't been released or reviewed on translate.wordpress.org

Home Page: https://wordpress.org/plugins/force-update-translations/

PHP 100.00%
wordpress i18n l10n internationalization internationalization-plugin localization translation wordpress-localization wordpress-plugin wordpress-translation

force-update-translations's Introduction

Force Update Translations

Description

Download WordPress theme/plugin translations and apply them to your site manually even if their language pack haven't been released or reviewed on translate.wordpress.org

Warning: Currently this plugin downloads only strings from Development project instead of Stable for plugins. Please wait for an update or see the issue on GitHub.

Warning: Currently this plugin is not able to generate the JSON files that is needed for JavaScript to consume some translations. Please wait for update or see the issue on GitHub.

Usage

Theme translation

Finally, updating theme translation files is now supported! To download the translation files for a theme:

  1. Activate the theme you want to get the translation files.
  2. Visit 'Appearance' > 'Update translation' in WordPress menu, or click 'Update translation' on theme details of current theme on 'Themes' page.

Plugin translation

To download the translation files for a plugin:

  1. Visit 'Plugins' in WordPress menu.
  2. Click 'Update translation' under the name of the plugin for which you want to get the translation files.

Changelog

= 0.5 =

  • Child theme support. props @pedro-mendonca

= 0.4 =

  • Bug fix for fresh installed WP. props @Dartui

= 0.3.2 & 0.3.3 =

  • Update tested up to versions.

= 0.3.1 =

  • Update locales.php and add WP.org variants support. props @pedro-mendonca

= 0.3.0 =

  • Added theme translation support.

= 0.2.5 =

  • Tested up to WP 5.5.
  • Minor grammar correction. Props @ePascalC
  • Added plugin icon. Props @mekemoke

= 0.2.4 =

  • Tested up to WP 5.2.2 props @pedro-mendonca
  • Check if if user Locale isn't 'en_US' props @pedro-mendonca

= 0.2.3 =

  • Add Multisite support. props @pedro-mendonca

= 0.2.2 =

  • Check if plugin exists in WordPress.org plugin directory. props @pedro-mendonca

= 0.2.1 =

  • Make target locale switchable by user setting. Thanks for reporting @Dartui
  • Improve escaping. Thanks for reporting @miya0001

= 0.2 =

  • Export only Current/Waiting/Fuzzy translations. props @naokomc
  • Capitalize plugin name.

force-update-translations's People

Contributors

dartui avatar epascalc avatar mayukojpn avatar naokomc avatar nekojonez avatar pedro-mendonca avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

force-update-translations's Issues

Update Screenshot.

Screenshot needs update:

  • Missing instruction with screenshot of updating theme translation.
  • Instruction for plugins would be nice to update with en_US UI.

Current screen shot:
image

[Suggestion] Hide update link for non wp.org plugins

A premium or private plugin isn't available in translate.wp.org, so clicking on the update link will always be a dead end.

A first option might be to just check if the plugin exists in the wp.org and only show the Update Translation if the plugin exists in the directory.

A second option, might be an option to add a particular link to a GitHub or custom/premium repo, as it happens in the settings of GP Auto Extract plugin.

Child theme support.

In most cases of trying to update the translation files of child themes, it intends to get the parent themes' one since this plugin is for translation.wordpress.org.

Waiting strings cannot be downloaded.

This plugins was designed to download unreviewed strings as we fixed on a1f5a1b . However, the filter doesn't look working properly anymore.

Need to check the current GlotPress specification.

So far I confirmed the direct link can get unreviewed strings:
https://translate.wordpress.org/projects/wp-plugins/wp-simple-booking-calendar/stable/ja/default/export-translations?filters[status]=current_or_waiting_or_fuzzy

GlotPress page of strings list.
https://translate.wordpress.org/projects/wp-plugins/wp-simple-booking-calendar/stable/ja/default/

I already tested to change "all" instead of "current_or_waiting_or_fuzzy" but it didn't work.

エスケープ漏れその他

たまたま目についたのでつっこみを。笑

  • 以下 esc_url() でエスケープするべき

https://github.com/mayukojpn/force-update-translations/blob/master/force-update-translations.php#L34

  • バリデーション漏れ。公式ディレクトリ上のWordPressプラグインのスラッグには半角英数とハイフォンしか使えない(?)と思われるので、正規表現等でそのようにチェックするべき。これはかなりやばい。笑

https://github.com/mayukojpn/force-update-translations/blob/master/force-update-translations.php#L52

  • エスケープ漏れ。esc_attr()esc_html()でエスケープするべき。

https://github.com/mayukojpn/force-update-translations/blob/master/force-update-translations.php#L138-L139

  • 同上

https://github.com/mayukojpn/force-update-translations/blob/master/force-update-translations.php#L71-L72

  • wp-に続く文字は半角英数以外(?)を想定する必要が無いのでは?この正規表現ではスラッシュも含めたすべての文字を通してしまうので、その後の file_put_contents() で任意のファイルをぶっ壊すことができる可能性があります。(実際にできるかどうかではなく、そういう心配をしなくてもいいようにするべき。)

https://github.com/mayukojpn/force-update-translations/blob/master/force-update-translations.php#L89

https://github.com/mayukojpn/force-update-translations/blob/master/force-update-translations.php#L105

  • esc_url_raw() でエスケープするべき。(esc_url() じゃないよ)

https://github.com/mayukojpn/force-update-translations/blob/master/force-update-translations.php#L125

エスケープは実際にそれが必要かどうかに関係なく使うシチュエーションにあわせてとりあえずやると決めるのが良いです。たとえばHTMLの属性に使うなら esc_attr() 、リンクに使用する URL なら esc_url() などのように利用目的に応じて問答無用でエスケープするのがよいです。

あとファイルに書き込むとかファイルを読み込むとかする場合は、特に慎重にやったほうがいいです。
https://ja.wikipedia.org/wiki/%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%88%E3%83%AA%E3%83%88%E3%83%A9%E3%83%90%E3%83%BC%E3%82%B5%E3%83%AB

Add links to GlotPress projects

it would be nice to direct users to translate.wordpress.org to update translation source. However, plugin action field looks too small to add 2 links and the string "Go to translation" is too long. I'm thinking of using icons instead of adding text:
image

Glotpress locale is different from WordPress locale

Hi, let's take Gutenberg plugin and Polish locale as an example.

If we change $locale variable in plugin to pl, we will have this URL to download translation:

https://translate.wordpress.org/projects/wp-plugins/gutenberg/dev/pl/default/export-translations?filters[status]=current_or_waiting_or_fuzzy&format=mo

This is totally correct, but will store it into gutenberg-pl.mo file. WordPress will not recognize it, because for Polish language the locale slug is pl_PL.

There are also another languages, which has two "segments" in locale. On GlotPress there are separated with dash, but WordPress requires underscore as separator (en-gb vs en_GB)

Add Themes support

The Update translation link might be added to the network themes list - hooked in theme_action_links.

For single site I didn't found any other action links hook, also can't think of a good place to insert the link, other than the theme details page.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.