I'm not sure where I should apply my "translate_from_glossary" method.
Par Fumito MIZUNO , 22 septembre 2014 ·
Hi Fumito,

As a matter of fact, we've been studying this kind of feature as it could be a huge improvment for Novius OS.
Using a glossary could be a way to indeed translate some words automatically, but we also believe it could be too risky.
Par Victor ALBERT , 22 septembre 2014 ·

Let's consider that this very specific word "apple" is in the middle of a huge text, and the glossary can only translate this word (not the other ones around) : it would be difficult to notice what's been translated or not.

Even when considering a way to highlight them, it would lead to a semi-translated text and would require to rewrite it anyway.

That said, it can still be usefull to translate very specific fields (such as keywords or categories) and a glossary could be used to automatically translate them. An application could be designed for this.

I imagine that a Behaviour with the list of fields to translate in its configuration would perfectly do the job.

Unfortunately, we won't have the opportunety to work on an application of that kind, but we can happily support you in its implementation. Would you consider it?

Anyway, do not hesitate to come back to us for more questions.

Edit : saw your message after posting my message
Par Victor ALBERT , 22 septembre 2014 ·

As I said, a behaviour could do the job.

If you can write a method like this on your behaviour :

public function crudConfig(&$config, $crud) {

//change values of each configured fields

  foreach($this->_properties['fields'] as $field) {

    if (isset($config['fields'][$field])) {

      //check if a "populate" callback has been defined, if so use it to define the new callback

      if (isset($config['fields'][$field]['populate']) && is_callable($config['fields'][$field]['populate'])) {

        $callback = $config['fields'][$field]['populate'];

        $config['fields'][$field]['populate'] = function($item, $data) use ($callback) {

           $value = $callback($value, $data);

            //perform translation on value using glossary


            //then return value

            return $value;


      } else {

        $config['fields'][$field]['populate'] = function($item, $data) {

            //perform translation on value using glossary


            //then return value

            return $value;






Let me know if this suits you!


Thank you for your suggestion.
I will try your code.

My plan is Glossary for Software names, City names, Company names, etc.
These words are easy to translate, because they are usually 1-to-1 translation, but difficult to translate, because spellings should be checked.
I hope it will help translators.
Par Fumito MIZUNO , 25 septembre 2014 ·
We look forward to see this app; do not hesitate to ask any other question, we'll be glad to help in its implementation!
Par Victor ALBERT , 25 septembre 2014 ·
    ou Annuler
Glossary. Translating words/phrases
Par Fumito MIZUNO , 22 septembre 2014

Novius OS allows to create a page from one language to another.

It will be much better, if some words/phrases are translated automatically.

When words are found in Glossary (apple => pomme, ...), they are translated.




Here is a sample code.


    function translate_from_glossary($content)


        // @TODO  glossary should be defined in config file or DB

        // @TODO  example is Englsh => Francais. but it should consider other languages.

        $glossary = array(





        foreach ($glossary as $from => $to)


            // words in the glossary will be translated.

            // separaters are space, period, and comma. start/end will be considered as separater

            // @TODO  capital letters. inflection.

            $from_regex = '(\s|\.|,|^)(' . $from . ')(\s|\.|,|$)';

            $to_regex = '\\1' . $to . '\\3';

            $content = mb_ereg_replace($from_regex, $to_regex, $content);



        return $content;