Translation of "Add new" dialog

11 views
Skip to first unread message

Edgar Rodríguez Silva

unread,
Sep 10, 2014, 11:55:33 AM9/10/14
to qubi...@googlegroups.com
Hello;

I have discovered one label that does not translate in the same way as the other labels and messages. The "Add new" label in dialogs like "Add new child levels" in the "Add archival description" form. 
This dialog is built with jquery, I have developed one simple solution to translate this dialog, including the next lines in js/multiRow.js 

var labelArrayLangs = new Array();
    labelArrayLangs['en'] = 'Add new';
    labelArrayLangs['gl'] = 'Engadir novo';    
    labelArrayLangs['es'] = 'Agregar nuevo';
var labelAddNew = labelArrayLangs[document.getElementsByTagName('html')[0].lang];

And I have modified the line :

$('<tfoot><tr><td colspan=' + ($(this).find('tbody tr:first td').length + 1) + '><a href="#" onclick="Qubit.multiRow.addNewRow(this); return false;">Add new</a></td></tr></tfoot>').appendTo(this);

by

$('<tfoot><tr><td colspan=' + ($(this).find('tbody tr:first td').length + 1) + '><a href="#" onclick="Qubit.multiRow.addNewRow(this); return false;">'+labelAddNew+'</a></td></tr></tfoot>').appendTo(this);


But now, I wonder if this is the best way to do it for a future maintenance.

What do you think?

Best regards

Edgar Rodríguez

Jesús García Crespo

unread,
Sep 10, 2014, 12:46:22 PM9/10/14
to qubit-dev
Hi Edgar,

The problem of your solution is that it's not integrated with the i18n extractor (symfony i18n:extract), which is responsible of finding all the i18n strings used in our PHP classes, templates and YAML fixtures under data/. With your approach, the literals that you define in multiRow.js would never make it into our XLIFFs documents neither in Transifex, making the translation workflow unmaintainable.

One solution that I'd like to see is a dynamic on-demand or pre-built (during deployment) JavaScript catalog that is loaded from our HTML pages. Ideally, one catalog for a specific language that includes all the strings that we are using in JavaScript, embedded into a hashmap like yours (labelArrayLangs) shared globally as a property of the Qubit global object.

This is a small example of what I am envisioning:


<html>
  <head>
    <script src="/index.php/i18n/catalog?sf_culture=es" type="text/javascript"></script>
    [...]
    <script type="text/javascript">
      console.log(Qubit.i18n['Add new']);
    </script>
  </head>
  <body>
    ...
  </body>
</html>

GET http://localhost:8000/index.php/i18n/catalog?sf_culture=es

Qubit.i18n = {
  'Add new': 'Añadir nuevo'
};

Django follows a similar approach. You can take a look at the views defined under django.views.i18n as a reference.

This could be a really cool feature and we would be happy to include it in AtoM! Let me know if you have more questions, Edgar.

Thanks,

--
Jesús García Crespo,
Software Engineer, Artefactual Systems Inc.
http://www.artefactual.com | +1.604.527.2056

Carolina Sacramento

unread,
Sep 10, 2014, 12:51:53 PM9/10/14
to qubi...@googlegroups.com
Great idea!

I think that solution could be incorporated in a new version, because we must to adjust this translation in each AtoM update available.

Thanks,
Carolina Sacramento
Oswaldo Cruz Foundation.



CAROLINA SACRAMENTO
Tecnologias da Informação
ca...@coc.fiocruz.br
55 (21) 3865-2241
Casa de Oswaldo Cruz | Fundação Oswaldo Cruz

--
You received this message because you are subscribed to the Google Groups "Qubit Toolkit Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qubit-dev+...@googlegroups.com.
To post to this group, send email to qubi...@googlegroups.com.
Visit this group at http://groups.google.com/group/qubit-dev.
For more options, visit https://groups.google.com/d/optout.

Jesús García Crespo

unread,
Sep 10, 2014, 5:41:13 PM9/10/14
to qubit-dev
Reply all
Reply to author
Forward
0 new messages