phrase/ios-sdk

tableName parameter is ignored, Phrase always returns from Localizable

Closed this issue · 9 comments

Simplified description of the situation: In our app there are several translation tables. One general table (Localizable) and one with tenant-specific content (Localizable-Tenant).

Without phrase (or more precisely before calling setup) we can get localizations from the different tables by specifying the tableName in NSLocalizedString(...).
After calling setup, the current version of Phrase (4.0.1) seems to ignore the tableName and always return localizations from the main table (Localizable), which may not exist.

In our case, this is even more critical because we have the following logic:
If there is a value for a key in the tenant-specific table take this value, otherwise, take the value from the general table. With 4.0.1, the tenant-specific table is completely ignored.

As a solution, we may could disable Swizzling, but that would introduce more complexity to the code. Thus, we are now back to version 3.0.1 where everything works as expected.

Hi Tobias,

Thanks for reaching out to us.
We'll look into this and get back to you as soon as possible accordingly.

Don’t hesitate to reach out again in case needed in the meantime, and have a great week ahead!

Best,
Erika from the Phrase Technical Support Team

Comment by Erika

Hi @winkelsdorf, could you maybe take a look at this issue and whether the behavior between the versions changed? Thanks!

@honkmaster Thank you for your issue report. We're currently re-evaluating the new logic to fit your needs, too.

I'll keep you updated here.

Thanks!

This ticket will reopen whenever you reply to it with any further questions or feedback.

Have a great week ahead.

Best,
Erika from the Phrase Technical Support Team

Comment by Erika

@honkmaster Could you please provide more information about your Bundle/Table Setup?

Using another Table e.g. OtherTable.strings I was able to access the strings using the swizzled method.

let otherTableValue2 = NSLocalizedString("othertable_test_key", tableName: "OtherTable", value: "", comment: "")
debugPrint("Other table", otherTableValue2)

That returned my value from the other Table correctly.

Am I right that you want to translate keys that might exist in both tables? In the example you would have a othertable_test_key in the OTA release and your other tables, too?

Hey @winkelsdorf @theSoenke . Why was the ticket closed? I did not have a chance to reply yet.

Regarding your question I may give you more details and clarify your question.

Our app has two tables.

  • Localizable.strings
  • Localizable-Tenant.strings

Both tables are available in for DE and EN.

We access the values as follows:

if let value =  NSLocalizedString("key", tableName: "Localizable-Tenant", value: "", comment: "") {
  return value
} else if let value =  NSLocalizedString("key", tableName: "Localizable", value: "", comment: "") { 
  return value
}

The key exists in both tables.

Before calling setup of Phrase, the logic above returns the values as wanted, here from Localizable-Tenant.
After calling setup, the first NSLocalizedString(...) still returns a value. But the value / string returned is from the Localizable table. This has led us to believe that tableName is ignored.

Additionally, for some of our apps there is only Localizable-Tenant. Here, after setup, no value is returned.

I hope the explanation helped and we kindly ask to reopen the ticket.

@honkmaster Sorry, that happened automatically by referencing it from our upcoming Release. Looking into your details later and giving you an update.

Thank you for the valuable input! We were able to fix the underlying issue and going to release later today. That said: Your custom tenant will work, but the Phrase OTA SDK only supports translating the Main Bundle (i.e. Localizable.strings). But it will not interfere with custom Tables anymore.

@honkmaster Release 4.1.0 has just been published. Please check if your problem has been solved, I am looking forward to your feedback.