I think I forgot to mention... Take care if you clear the whole file, you will probably lost your good translation...
So maybe make a copy of the file and then you can write a simple script that compare both dict the old one and the new generated dict store into tranlation file than import just the tranlated entry when they are present in the new transltation file... Dam dam you have your automatic clean up script... Richard On Wed, Sep 28, 2011 at 9:18 AM, Thomas Bellembois < thomas.bellemb...@gmail.com> wrote: > ** > That is exactly what I needed ! Thanks a lot. > > Regards, > > Thomas > > Le 27/09/2011 22:52, Richard Vézina a écrit : > > And since the file is always rebuild... If he wants to clear old stuff he > just can earase the entire file if he wants. > > Also, imagine you want to keep some translation into DB... You can use > something like that : > > # > ----------------------------------------------------------------------------- > # GET FROM DICT_DATABASE FIELD NAME TRANSLATION > # > ----------------------------------------------------------------------------- > def update_fr_ca(db, request): > import os > import gluon.portalocker > import cPickle > from gluon.languages import read_dict, read_dict_aux, utf8_repr, > write_dict > from gluon.cfs import getcfs > # > -------------------------------------------------------------------------- > > # > -------------------------------------------------------------------------- > language = 'fr-ca' > filename = path_to_file(request, 'languages/', '%s.py' % language) > #filename = os.path.join(path, '%s.py' % language) > > language_fr_ca = read_dict(filename) > > dict_database_ui_en_fr = db(db.dict_database.table_name_en_ui != > None)\ > .select(db.dict_database.table_name_en_ui.name, > db.dict_database.table_name_fr_ui.name, > distinct=True) > > > language_fr_ca.update(dict((row['table_name_en_ui'],row['table_name_fr_ui']) > for row in dict_database_ui_en_fr)) > > # > -------------------------------------------------------------------------- > write_dict(filename, language_fr_ca) > # > -------------------------------------------------------------------------- > > # > ----------------------------------------------------------------------------- > > > I put this in module and call it in my model once when I change some > translation into my dict_database table... > > Richard > > On Tue, Sep 27, 2011 at 4:45 PM, Richard Vézina < > ml.richard.vez...@gmail.com> wrote: > >> Web2py already add all the things put between the parantesis after the >> magic T() when you clic updates languages button from the admin... >> >> I think Thomas want to clean his language file from old entry or not >> translated ones... In the first case I see no easy way except someone as you >> said write a script... In the second case the yellow box (not translated >> entry) why not just leave them there... They will always be returning in the >> language files anyway... >> >> Richard >> >> >> On Tue, Sep 27, 2011 at 4:16 PM, Alex <mrauc...@gmail.com> wrote: >> >>> I guess it should be quite easy to write a script which scans all the >>> py files for labels and compares them with the labels from the >>> translation file. Maybe a script like this already exists? >>> >>> Alex >>> >>> On 27 Sep., 21:29, Richard Vézina <ml.richard.vez...@gmail.com> wrote: >>> > What do you mean, the untranslated yellow background entry or the old >>> entry >>> > not good anymore? >>> > >>> > Richard >>> > >>> > On Tue, Sep 27, 2011 at 11:21 AM, Thomas Bellembois < >>> > >>> > >>> > >>> > thomas.bellemb...@gmail.com> wrote: >>> > > Hello, >>> > >>> > > Is there a way to clean up unused translation strings ? >>> > > I have googled the question without success... >>> > >>> > > >>> http://www.mail-archive.com/**web2py@googlegroups.com/**msg06533.html< >>> http://www.mail-archive.com/web2py@googlegroups.com/msg06533.html> >>> > >>> > > Regards, >>> > >>> > > Thomas >> >> >> > >