Translation not Working for Custom Apps

Hello I’ve developed a custom app, and now I’m looking to translate to spanish, this are the steps I’m doing, following the officiald Documentation Instructions and also other official docs translation instructions.

  1. Get the Untranslated strings, I have the app installed. bench --site mysite.localhost get-untranslated es-CO ./es-CO-untrans.csv Also get-untranslated did not work and show an error until I applied this PR changes to bench

  2. Find the files ./es-CO-untrans.csv in /sites, make a copy of it named es-CO.csv.

  3. Edit es-CO.csv changing each line I want to translate from english to spanish. as:

    File before:

    my number
    my other number
    

    File after:

    mi numero
    mi otro numero
    
  4. Update the translations bench update-translations es-CO es-CO-untrans.csv es-CO.csv

  5. Add my language to /apps/language.txt althought this seems uneccesary seems I’m not bootstrapping a new language.

  6. Check if the translation were created in my custom app, apps/custom_app/custom_app/translations/es-CO.csv.

  7. Check the content of the added translation.

    b'DocType: Package',b'my number',b'mi numero'
    b'DocType: Package',b'my other number',b'mi otro numero'
    
  8. Now I restart the bench, clear chache, set site to not cache at all, change my language, change it back, migrate the bench, update, etc. Nothing works, I still get the strings in english.

And It just doesn’t work. The only way I can get translations to work is by Using the GUI on desk#List/Translation/List. Is also so not user friendly that bench get-untranslated seems to be broken for a year an someone submitted a PR and issue, and both are ignored.

Environment

erpnext 12.10.1
frappe 12.8.1
# This is my application in which I'm testing
package_management 0.0.1

So the question remains, how does one create translations for a custom app?

4 Likes

I hope you will not also be ignored.

2 Likes

Hello! Been trying to get attention into this issue. Seems like a very crucial part of the framework. Decided to write my app in English to then translate and ended up with tons of problems in this aspect. I also commented in [Release Notes] bench v5.2.0 - #5 by Javier_Lopez, but still no answer! Might be helpful If you comment as well :+1:

1 Like

It’s really worrying when core developers ignore PRs for obvious problems.

I have only recently begun a customization and a new module. Like you, I thought it would make sense to do it all in English . It never occurred to me that I18N and L11N would simply not work.

Is it possible you have missed something, for your current version perhaps?

Has an issue been created in GitHub?

The issue in the Frappe repo exists.

About missing steps, I followed everything I could find and tried anything I could think of and I didn’t work. And haven’t been able to get answers, asked around on the Not Official Telegram Channel and no one commented on it. Also red all I could find in the forum but nothing seems to help.

But I lean on in being a bench problem, since you can’t even get the untranslated strings, that just tells me there’s probably no test for it, and not many people using it I guess.

1 Like

They have a surprising number of languages and a large number of modules.

If translations simply don’t work, how do they do all that?

Well they seem to have something bootstrapped for ERPNext languages see: https://translate.erpnext.com/ I don’t know if it uses bench. That’s not what you do in a custom app. I hope I’m wrong an I’m just doing something dumb. So I can fix it and help documenting the issue.

1 Like

I have opened a new bug report on the bench repo, hopping to get some traction on it.
https://github.com/frappe/bench/issues/1071

1 Like

Looking to follow up on the subject, the above mentioned issue has been closed and a PR has been merged. Fixing the csv generation to translate, but sadly translation is still not possible.

Issue:
https://github.com/frappe/frappe/issues/11488

PR:
https://github.com/frappe/frappe/pull/11629

Now that the steps of generating the untranslated strings work bench --site mysite.localhost get-untranslated es-CO ./es-CO-untrans.csv when you make the neccesay translations and go to update there’s an error:

So update-translations es-CO es-CO-untrans.csv es-CO.csv doesn’t work, here’s the new bug report:

https://github.com/frappe/frappe/issues/11738

Sadly It’s still not possible for custom translations in this ERP. :upside_down_face:

Good news, today I worked in fixing bench update-translations and submitted a Pull Request

https://github.com/frappe/frappe/pull/11785

I tested in my instance and It worked, finally got some translations in my app, I’m excited, I hope the PR I submitted is good enough, and translations might work!!

I believe the main issue in all this is that the code is over 5 years old, and using some python modules like csv that have had api changes when moving to python 3 and some things have not been migrated properly.

Something I noticed now that translations are working, is that this should not be the output of bench update-translations file, It should show without the b' which are python way of representing encoded strings.

b'DocType: Package',b'my number',b'mi numero'
b'DocType: Package',b'my other number',b'mi otro numero'

@MartinHBramwell Just letting you know in case you’re still interested!

1 Like

I’m happy to say the PR was merged and translations are working well for me! The problem was that update-translations would generate incorrect translations when it worked, as can be seen in step 7 of the original post. The correct output is similar but without b' and all strings properly encoded.

2 Likes

This should still be broken. I bet (sadly), that you can not add new strings to your app, and run the same (official) cycle of bench get-untanslated... → translating → bench update-translations again.
I would be highly interested, if this works for you. For me it doesn’t.

The first time it works, and after that it will just override, whatever was already translated.

@Javier_Lopez
I do have a dirty, and hacky codefix, which I did not yet bother polishing for a mergerequest, since I am still not sure, if I do something wrong. In case you want to try, and can reproduce my Problem, feel free to experiment: Commits · alias/frappe · GitHub (Bunch of new patches since Oct. 27 where I merged your fixes)

Hi I am just wondering how do you mange those untranslated strings outside of your custom app? When I do get-untranslated I get >4k untranslated strings and I have not capacity to translate all of them but only for my custom app. How do I get ride of these untranslated strings?