Set fallback language for interface translations to french

Hi - In the Soumraye Bible app we have added Soumraye as an interface language, in addition to English and French. We then added the translations for: book, chapter, verse, old testament and new testament.
We would like all other terms to appear in French, but if we uncheck English as an interface language, the Soumraye language also disappears. We do not see any place to set the ‘fallback’ language for the app translations to french - that seems to default to English. (On the languages tab there is a place to define the fallback language if the system language of the users device is missing translations, that we have set to french). I also set my samsung a5 phone to use french, but when I set the interface language to soumraye in the app, all other translations revert to English.

Surely there is a way to do this? Thanks for your help …

Well, you certainly could click on the tab “Traductions” and copy the translations from the French tab to the Soumraye tab. Then you wouldn’t be counting on the fallback language at all - everything would be specified in the Soumraye interface (even though most of the translations would actually be French…).

That copy/paste would be a little tedious (but not horrible), since I believe you would need to copy phrases one at a time from one tab to another. It may be possible to make the copies automatically, with SAB closed, and opening the .appDef file with an editor that can handle regular expressions. Try the following:
Find: ((\s+)<translation lang="fr">(.*?)</translation>\r\n)
Replace: \1\2<translation lang="sor">\3</translation>\r\n
This should copy the French translation line and paste it as a new line for Soumraye (untested). If you have some translations already in Soumraye, you would need to manually remove those extra lines copied for those translations. As always, if you want to play around with the .appDef file, make a backup copy BEFORE making any changes that you can go back to, if necessary!

Hi Jeff, thanks for the suggestion.
We tried the find replace in notepad++, but the search with that first string returns 0 hits… I am guessing there is something wrong with the syntax, (which I don’t understand at all). Here is the part of the appdef file where I would have expected it to return the first hit:

I would not know where to start fiddling with the string.

And as you noted, copying the translations from the french column to the soumraye column would mean switching between tabs line by line. It would be much less tedious if there was a way to display the french column on the same screen as the english and soumraye…

The best way to “fiddle” with a regular expression is to try to find just a part of the string, and then keep adding parts of the search string, and try to see where the search breaks down. E.g. it should be able to find <translation lang="fr"> without too much difficulty. Then add other parts of the string, to see where the search stops working.

Are you on a Windows machine? If not, it may be the end of line characters that aren’t matching. Why don’t you play with it a little bit. If you don’t find a way forward, maybe you can attach the .appDef file, and I can take a look.

Hi Jeff,
thanks for the nudge. I am on a windows machine.
This time I tried with atom… and I got 251 hits with <translation lang="fr"> … but as soon as I added any of the rest of that string I got nothing… until I noticed a couple buttons next to ‘finding with Options’ and clicked on the one [ .* ] (regex, case insensitive)

Now it finds all 251, but when I replaced the first one I realize it is not adding sor in addition to french, but simply overwriting the french, and without the translation included.

  1. I don’t want to write french out of the translation section.
  2. It is not even copying the french term to write it into the sor line
  3. it is not pretty - no line breaks.

So begins the fiddling. I wanted to say at this point something cute like, 'I can’t regex my way out of a wet paper bag. (I suppose if I was in a wet paper bag with nothing else to do and a good reference I might teach myself in time). Well, google turns out to be a good reference. I assumed that your replace expression was meant (in plain english) to look something like this:
find each string with
copy the whole line and paste it on a new line, replacing the “fr” with “sor”

Turns out that with a little help from google (atom regex),
I just needed to replace \1 \2 and \3 with $1 $2 and $3.
I now get an extra line between the fr and the sor, but I am not going to fuss about that.
Again what learned.

I’m glad that I didn’t give you too much to go on, because the things you struggled to learn will be remembered much longer! :slight_smile:

But just to clarify some of the lessons learned:

  • You need to make sure that regular expressions are “turned on” in the search
  • Some flavors of RegEx use different syntax - you should be able to find more help, and even examples, in the help for your editor program; the backslashes are more standard, but the dollar signs are used by some, as you so cleverly discovered
  • When you are posting in the community, some things need to be marked as preformatted text, using the image tool, in order for them to show up in the post (like your “find each string with [empty]” in your last post)

The reason you have an extra line in the output is because the line break (\r\n) actually seems to be matched by the \s+ term, so it is repeated. I think all of that space at the beginning of the line is spaces in the .appDef file, so if you don’t want to match that line break, you can change the \s to a simple space. So the search line becomes:
(( +)<translation lang="fr">(.*?)</translation>\r\n)
(with a space before that first + sign) Give that a try to see if it prevents the blank line.

For learning RegEx, I would recommend using: You can put your text in TEST STRING, and try out different REGULAR EXPRESSIONs to see how the match happens. There is even a detailed EXPLANATION to the right which breaks the RegEx apart, MATCH INFORMATION, and a QUICK REFERENCE on syntax. And there is a Substitution function to the left, that allows you to test replacement as well. (To see if you would end up with an extra line or not.)

Note that when I put the expression above into the REGULAR EXPRESSION, it actually says that there is a syntax error: it says the “/” character needs to be escaped with a backslash, i.e. <\/translation>. My particular flavor of RegEx (in EditPad Pro) doesn’t require that, but it is allowed (and handled properly), so that’s probably better form… And the Substitution function uses the $1, $2 syntax for the contents of the capture group. And the end of string if I just paste some lines in from the .appDef file seem to end with a \n and not a \r\n.

So lots of fun variations to navigate, but trial and error is your friend… :slight_smile:

thanks again.
I have now tested it in SAB and after a bit more fiddling and a couple more lessons that I learned (and some that I still need to learn before my next attempt), it seems to work satisfactorily.
Here is what was still needed for things to work right:

  • once it got going on replace all, Atom didn’t give me a message like ‘reached end of file, 251 replacements made’ … I didn’t have any feedback as to whether it was still working or what was happening (lesson: find out how to stop a process… escape? ctrl c? I went with ctrl-z - and while that doesn’t seem strictly correct it did seem to stop the find and replace process…)

  • It appears to have started through the file from the top again, and since the “fr” translations were all still there, it was replacing them a second time. Whether just lucky timing or the extreme slowness of Atom I read about in the atom regex site, it had only gotten through two or three entries on the second pass, which I could manually clean out. (lesson: find out how to make it stop at the end of the file. I didn’t see anything obvious in the find replace panel…)

  • although my fr and (copied) sor translations all appeared now in the appdef file, it was not appearing in SAB on the interface soumraye translations tab. I did one manually and went out to look at it - we had put sor and it wanted SOR. (lesson: lg. codes are case sensitive in the appdef…)

  • an easy find replace, except I hadn’t learned the lesson about stopping at the end of the file, and the find with options was set to ‘case insensitive’ so I presume it was going through replacing SOR with SOR in an infinite loop. Turning on the case sensitive button fixed that.

  • I did also need to manually go in and delete the lines generated with find&replace for book, chapter verse etc.

  • and the last thing was, (I think) somewhere in the process of opening and saving and closing things in SAB, it sorted the SOR translations down to the end of the language list in each interface term section without me trying to make that happen. (When running the replace command as described, those lines all initially followed the french translation high in the language list.)

So this does still seem like the hard way to do it… there should be a place where you can set the fallback language for an incomplete localization to the appropriate regional language… does this need to be more carefully worded as a fresh topic and flagged as a feature request?

I would be REALLY surprised if search/replace all doesn’t stop after it has gone through the entire file. Maybe there is iterate option somewhere that is checked? It is typical in search/replace operations, that if you test a couple before saying replace all, that you will have to go back and manually fix the first couple of replacements.

Yes, I would encourage you post as a feature request the ability to choose a fallback language. It would probably be a dropdown menu that would allow you to choose any of the activated languages. Of course, if you deactivated a language that was selected it would need to handle that.