Extends String with a 'translate' method. Returned value is the according translated text for a Wordpress Post translated by QTranslate plugin.
Add this line to your application's Gemfile:
gem 'q_translate'
And then execute:
$ bundle
Or install it yourself as:
$ gem install q_translate
Extends String with a 'translate' method. Returned value is the according translated text for a Wordpress Post translated by QTranslate plugin. Useful for Wordpress integration in a Rails app where the admin bloggin side is handled by Wordpress Engine. The default value if translation is not provided is English.
$ post = WpPost.first
$ post.post_title
$ => "<!--:en-->And this is how the Universe ended.<!--:--><!--:fr-->Et c'est ainsi que l'univers connu cessa d'exister.<!--:-->"
$ I18n.locale = :en
$ post.post_title.translate
$ => "And this is how the Universe ended."
$ post = WpPost.first
$ post.post_title
$ => "<!--:en-->And this is how the Universe ended.<!--:-->"
$ I18n.locale = :fr
$ WpPost.first.post_title.translate
$ => "And this is how the Universe ended."
$ post = WpPost.first
$ post.post_title
$ => "And this is how the Universe ended."
$ I18n.locale = :fr
$ post.post_title.translate
$ => "And this is how the Universe ended."
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request