AHTranslator missingTranslations - how are they collected?

Penko

Active Member
Licensed User
Longtime User
I have a simple question. At what point the missing translations are added to the MissingTranslations map? I've translated some 10 activities and have gone through all of them in my application but nothing is being added to the Map before I write it to a file with WriteTranslations(). What is the mechanism, aren't the values persistently stored as soon as process globals is alive?

I save the items to the file on Activity_Resume of my menu activity. Okay, first time, there should be no info how much the items are. I then make a big walk around all activities and get back to the menu with the hope that everything has been added to the missing translations. But it is not. Only the "dummy line" I call before WriteTranslation is added.

This behaviour is pretty strange - because on my activities, all labels get the text properly(Instead of using English directly, I am using keys). Example:
USEREDIT_FIELDS_USERNAME
USEREDIT_FIELDS_PASSWORD

I have this:

B4X:
Sub initializeTrans()

   Try
      trans.Initialize2(File.DirAssets,  "lang", locale.Language)
   Catch
   
   End Try

End Sub

Sub initializeLocale()

   Dim isInitialized As Boolean : isInitialized = locale.initialized 
   
   zCommon.LogT("initializeLocale() isInitialized = " & isInitialized, "")

If(isInitialized = False) Then
   locale.Initialize
End If

End Sub

Sub tr(KEY As String) ' I am using this method to isolate the AHTranslator translator logic from being used directly.

'zCommon.LogT("tr() KEY = " & KEY, "")

   Dim result As String 

   Try
       result = trans.GetText(KEY)
Catch

   zCommon.LogT("tr() LastException = " & LastException, "")

   initializeLocale
   initializeTrans

   result = trans.GetText(KEY)
End Try

Return result
End Sub

Sub WriteLanguageFile()

If(zAppSettings.debug_mode = False) Then
   Return 0
End If

Try
      initializeLocale
      initializeTrans
Catch

End Try

Try

zCommon.LogT("locale = " & locale.AvailableLocales, "")

trans.GetText("THIS DUMMY LINE WILL BE ADDED TO THE TRANSLATIONS MAP BUT MY OTHER 100 ITEMS IN THE OTHER ACTIVITIES WONT)

   trans.WriteTranslation(File.DirDefaultExternal, "lang")
   zCommon.LogT("WriteLanguageFile -- it was written", "")
Catch
   zCommon.LogT("WriteLanguageFile - exception = " & LastException, "")
End Try

zCommon.LogT("WriteLanguageFile() trans = " & trans.MissingTranslationMap, "")
   
End Sub
 

Penko

Active Member
Licensed User
Longtime User
Markus, unfortunately I couldn't reproduce the problem with a small project.

I am acting very similarly as I do in my other project but the key pairs are being added to the map perfectly. In my work project, the fail.

I even tried using CallSubDelayed which I do most in my project but it's not the problem.

I will now remove all try/catch blocks related to AHLocale to see if there is some exception which is being caught but I hardly believe this is the reason.

Also, I linked all libraries I've linked in my official project to check if is is a compatibility issue but no success too.
 

Attachments

  • AHLocaleExample.zip
    11.3 KB · Views: 244
Upvote 0
Top