Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Localization issues #602

Open
Hatsushira opened this issue Jun 14, 2021 · 22 comments
Open

Localization issues #602

Hatsushira opened this issue Jun 14, 2021 · 22 comments

Comments

@Hatsushira
Copy link
Contributor

Hatsushira commented Jun 14, 2021

Dear all,

I had a break on working with CareKit for a while, so it's possible this issue exists for longer than just now. I'm currently on Xcode 12.5 and on the main branch. I linked the CareKit libraries with the github link to source code and the libraries are linked and working. What happens to me now is that the UI elements of CareKit aren't translated anymore. But this works in an older version of CareKit (approx Dec. 2020) on my parent's iPad.

I switched on the missing phrases option in Xcode and this is on of the error messages I'm getting.

2021-06-14 20:39:04.583255+0200 PHR[7363:110426] [strings] ERROR: Log not found in table Localizable of bundle CFBundle 0x7fb887463bc0 </Users/username/Library/Developer/CoreSimulator/Devices/BD1C21E8-9CC2-4E46-93C0-628CDB6435D0/data/Containers/Bundle/Application/4D7CEFDB-13D8-4992-BD59-768E600BCB3A/PHR.app/CareKit_CareKitUI.bundle> (not loaded)

Log not found means that it is actually processed by the function, because the phrase is "LOG" but it's not translated. So could you help me with any ideas or is it perhaps related to the following commit #566 ?

@erik-apple
Copy link
Collaborator

Thanks for reporting this Hatsuhira! Can you tell us how you're including CareKit in your app? Are you using an Xcode subproject or SPM?

@Hatsushira
Copy link
Contributor Author

Hatsushira commented Jun 16, 2021

I use SPM with your first option described in your readme. I add a dependency to the main branch.
Currently, I watch this issue on the OCKButtonLogTaskView. The phrase LOG is "translated to Log, COMPLETED to Completed and the same goes for the options if you double click on a completed entry to remove it. But they're not translated in the other language.
Additionally, I have custom versions of the OCKButtonLogTaskView, all my added fields labels etc. are translated, but the Log Button is not.

@erik-apple
Copy link
Collaborator

Thanks for the explanation. Allow me to ask a few follow up questions.

The phrase LOG is translated to Log, COMPLETED to Completed...but they're not translated in the other language.

Is your app localized to any languages other than English?
Do you have a Localized.strings file in your own app that is supposed to provide translations for the other languages?

@Hatsushira
Copy link
Contributor Author

Hatsushira commented Jun 16, 2021

Yes, in German.
Yes, I do have a Localizable.strings file and a Localizable.stringsdict. I copied all the phrases in these files as suggested.
My app is translated in all other areas. I only experience this problem with the button log. I attached some images for you. As you can see in the second picture the phrases of the stringsdict are used. On the button log they're not.
https://ibb.co/gwD3QTH
https://ibb.co/0BBNcnV

@erik-apple
Copy link
Collaborator

The fact that most of your translations are being picked up leads me to believe that your localizations bundles are being discovered as intended. "LOG" and "COMPLETED" appear to be the correct keys as of the latest commit. Can you confirm that your German localization files contain they correct keys? For example, you might have "COMPLETE" instead of "COMPLETED".

@Hatsushira
Copy link
Contributor Author

Hatsushira commented Jun 16, 2021

Unfortunately, yes. They are all in. These are my contents for the CareKit Part.

Additional information: I have a SwiftUI app and use UIViewControllerRepresentable to show these screens. Perhaps it's related to this?

// MARK: CareKitUI
"ADDRESS" = "Adresse";
"ANNOUNCE_EVENT_DELETED" = "Aufgezeichnetes Event gelöscht";
"BEGIN" = "Start";
"CANCEL" = "Abbrechen";
"CALL" = "Anrufen";
"CLOSE" = "Schließen";
"COMPLETED" = "Abgeschlossen";
"CONTACTS" = "Kontakte";
"DELETE" = "Löschen";
"DONE" = "Fertig";
"DOUBLE_TAP_MAP" = "Doppelt Tippen um auf der Karte anzuzeigen";
"DOUBLE_TAP_TO_COMPLETE" = "Doppelt Tippen um Abzuschließen";
"DOUBLE_TAP_TO_INCOMPLETE" = "Doppelt Tippen um es zu aktivieren";
"DOUBLE_TAP_TO_RECORD_EVENT" = "Doppelt Tippen um ein Event zu markieren";
"DOUBLE_TAP_TO_REMOVE_EVENT" = "Doppelt Tippen um das Event zu löschen";
"EMAIL" = "E-Mail";
"EVENT" = "Event";
"GOAL" = "Ziel";
"HIGH" = "Hoch";
"INCOMPLETE" = "Nicht abgeschlossen";
"LOG" = "Aufzeichen";
"LOG_ENTRY" = "Eintrag";
"LOGGING" = "Aufzeichnen";
"LOW" = "Niedrig";
"MARK_COMPLETE" = "Als abgeschlossen markieren";
"MESSAGE" = "Nachricht";
"NO_DATA" = "Keine Daten";
"NO_TASKS" = "Keine Aufgaben";
"NO_EVENTS" = "Keine Events";
"PROGRESS" = "Fortschritt";
"SEARCH" = "Suchen";
"SELECTED" = "Ausgewählt";
"TASKS" = "Aufgaben";
"THREE_FINGER_SWIPE_DAY" = "Mit drei Fingern wischen um zu nächsten oder vorherigen Tag zu gelangen";
"THREE_FINGER_SWIPE_WEEK" = "Mit drei Fingern wischen um zur nächsten oder vorherige Woche zu gelangen";
"TODAY" = "Heute";

@erik-apple
Copy link
Collaborator

Thanks for providing your translations! That should help a lot.
We'll start digging into this a bit more.

@Hatsushira
Copy link
Contributor Author

Hatsushira commented Jun 16, 2021

Thank you Erik, I really appreciate your help. Just because I'm curious I switched the CareKit dependency in my project back from main to master branch and what can I say. There it works. Switching back to main the phrases aren't translated anymore.
https://ibb.co/CtjvGNf

@gavirawson-apple
Copy link
Collaborator

Hi @Hatsushira! I tried to reproduce the issue you're seeing, but haven't had any luck. On the main branch, the strings seem to be displaying in German as expected:

I wonder if there's something I'm missing here that's causing the underlying issue. Are you still seeing an issue on your end? If so, what was the process you went through to add the German strings to the project?

@Hatsushira
Copy link
Contributor Author

Hi @gavirawson-apple thank you for you help Yes, I'm still facing this issue.
I added a group Localization to my main project and added Localizable.strings and Localizable.stringsdict to it. Then for Localization I chose English and German. Then I copied the phrases from CareKit into those files and translated them. Basically, that's it.

@gavirawson-apple
Copy link
Collaborator

Gotcha, thanks for the info. Was the process you went through somewhat like like the instructions here?

@Hatsushira
Copy link
Contributor Author

Yes, I'm sorry, that I'm not very helpful. The weird thing is that when I switch back to the master branch here from this repository it does work. The only change is the repository, my code stays the same. Perhaps it has something to do with my directory structure?
https://imgur.com/mqwexQv

@gavirawson-apple
Copy link
Collaborator

No worries at all! All the information you've been giving has been super helpful. I'm trying to think how our setups might be different, I'm also testing the localization on Xcode 12.5.

I think you're on to something with the directory structure. Mine looks a bit different from yours:

Screen Shot 2021-07-01 at 12 50 48 PM

I'd recommend starting from scratch and seeing if the issue is still there, is that possible on your end? You can add a German strings file by navigating to and tapping the circled "plus" button below:

Screen Shot 2021-07-01 at 12 52 35 PM

@Hatsushira
Copy link
Contributor Author

Hatsushira commented Jul 1, 2021

So, I created a complete new Xcode project, with only the standard Base and English as development language, added my files and was able to run the project. I enabled the missing localizable strings in the run options. Then I run the projects and I got all the missing phrases warnings as expected.
Then I added a localizable.strings only for English. All phrases were translated but for the Log phrase I got the warning that it's missing in the package. I think for the Button Log CareKit only looks in the CareKit package for the phrase and not in my project's package. CareKit is only linked and it's read only for me. I just added the repository as link.

This is my project overview.

https://imgur.com/i2nf7Ax

The only change after switching from master to main branch with a reference to language is this commit.
7dfcdef

This is my controller where I create the OCKButtonLogTaskViewController

import Foundation
import UIKit
import CareKit
import CareKitStore
import SwiftUI

class DailyPageViewController: OCKDailyPageViewController {
    
    var store: PatientStore!
    
    init(store: PatientStore) {
        super.init(storeManager: OCKSynchronizedStoreManager(wrapping: store.store))
        self.store = store
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        view.tintColor = UIColor(Color.blue)
    }
    
    // This will be called each time the selected date changes.
    // Use this as an opportunity to rebuild the content shown to the user.
    override func dailyPageViewController(_ dailyPageViewController: OCKDailyPageViewController,
                                          prepare listViewController: OCKListViewController, for date: Date) {
        
        var query = OCKTaskQuery(for: date)
        query.excludesTasksWithNoEvents = true
        
        store.store.fetchTasks(query: query, callbackQueue: .main) { result in
            switch result {
            case .failure(let error):
                print(error.printError(error.localizedDescription))
            case .success(let result):
                if result.contains(where: { $0.id == "drink" }) {
                    let drinkCard = OCKButtonLogTaskViewController(taskID: "drink", eventQuery: .init(for: date),
                                                                   storeManager: self.storeManager)
                    
                    listViewController.appendViewController(drinkCard, animated: false)
                }
                var tasksInStore = result.filter({$0.groupIdentifier == MenuEntity.PhrMedicament.rawValue})
                tasksInStore = tasksInStore.sorted(by: { $0.title! < $1.title! })
                
                var idsAsString = [String]()
                idsAsString.removeAll()
                
                for task in tasksInStore {
                    idsAsString.append(task.id)
                }
                
                for id in idsAsString {
                    let card = OCKGridTaskViewController(
                        taskID: id,
                        eventQuery: .init(for: date),
                        storeManager: self.storeManager)
                    listViewController.appendViewController(card, animated: false)
                }
            }
        }
    }
    
}

@gavirawson-apple
Copy link
Collaborator

Thanks for all of the info! I believe the source of the issue has something to do with SPM. We're investigating and will let you know when we have a fix. In the meantime, if you'd like, you can embed CareKit in your app rather than using SPM. That will allow you to add a German strings file directly to the framework, which works on my end.

@Hatsushira
Copy link
Contributor Author

Thank you for your assistance.

@Hatsushira
Copy link
Contributor Author

I have additional information:
I cloned this repo on my own server. Added localization files to the localization folder of CareKitUI and I get the expected behaviour, that the phrase actually is translated to German in the user interface. BUT: I still get the error in the console:
2021-07-18 22:16:14.589849+0200 PHR[59554:606556] [strings] ERROR: Log not found in table Localizable of bundle CFBundle 0x7ff086d3dd80 </Users/gerdgrossmann/Library/Developer/CoreSimulator/Devices/14DB5404-A621-4377-9283-D01079AFA810/data/Containers/Bundle/Application/869B73F3-A3B3-42E2-A2F8-119BB3C51804/PHR.app/CareKit_CareKitUI.bundle> (not loaded)

@gavirawson-apple
Copy link
Collaborator

That is very strange, I haven't seen that one before! Perhaps it only happens in the simulator.

@Hatsushira
Copy link
Contributor Author

Me, neither. Perhaps my project is somehow messed up.

I got my localization now working and can move on. Thanks again for your patience.

@gavirawson-apple
Copy link
Collaborator

Of course! Glad things are working. It may take some time, but we will solve this SPM+Loc issue on our end!

@zxcheergo
Copy link

How do you get the Localizable.strings file ?

@zxcheergo
Copy link

Is there any tutorial on how to add the localization on CareKit? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants