bytesource Posted November 4, 2014 Share Posted November 4, 2014 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 More sharing options...
Nico Knoll Posted November 4, 2014 Share Posted November 4, 2014 Why not just using a custom function on runtime? Like <?php echo bingTranslate("Some static dummy text") ?> Or do you want to save them? Link to comment Share on other sites More sharing options...
bytesource Posted November 5, 2014 Author Share Posted November 5, 2014 Yes, I want to save the translations to be able to make corrections later. Link to comment Share on other sites More sharing options...
Nico Knoll Posted November 6, 2014 Share Posted November 6, 2014 You may could use ProFields Table for that. I did it before and it works great. Link to comment Share on other sites More sharing options...
bytesource Posted November 7, 2014 Author Share Posted November 7, 2014 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: Get all translatable files of the 'template' folder and its subfolders. Extract all translatable sentences Do an automatic translation for language x (I already solved this one for other field types, like FieldtypeTextareaLanguage) 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 More sharing options...
kixe Posted November 11, 2014 Share Posted November 11, 2014 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. Link to comment Share on other sites More sharing options...
bytesource Posted November 11, 2014 Author Share Posted November 11, 2014 @kixe I always wanted to take a look at the actual code, but I just did not know where to look. Thanks a lot for pointing me into the right direction! Cheers, Stefan 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now