Jump to content

Retrieve & Set The Language Value of Translatable Static Text _("...")


bytesource
 Share

Recommended Posts

Hi all,

I am planning to have the initial translation of a site of mine done automatically via Bing's translation API, and I therefore need to retrieve all translatable static text,  like

<?php echo _("Some static dummy text") ?>

and set the language value.

Is there a way to do this using the Processwire API, or do I need to manually export the translation file?

Cheers,

Stefan

Link to comment
Share on other sites

Thanks for this suggestion. I read the introduction about the ProFields Table field type, but to be fair, I could not see how to use them to my advantage in this case.

I am looking for a way to do the following via the API:

  1. Get all translatable files of the 'template' folder and its subfolders.
  2. Extract all translatable sentences
  3. Do an automatic translation for language x (I already solved this one for other field types, like FieldtypeTextareaLanguage)
  4. Set and save the translation

Alternatively, exporting all the sentences as JSON would help, too. Then I could just export the data via code, add the translations, and import the data again.

I am pretty sure the above is possible, I just don't know where to look for the relevant information.

Cheers,

Link to comment
Share on other sites

Have a look in the core module LanguageTranslator and in my module LanguageTranslatorPlus. You will find functions there to find translatable files and also something to extract translatable strings and also something to create jason-files. Make a new function to use bing Api and something to save.

If you put this together nicely it would be a useful module for everybody. :rolleyes:

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...