-
Notifications
You must be signed in to change notification settings - Fork 48
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
Updating the language for a tableview with separate tableviewcell files #43
Comments
@jrumol Hi, thanks four your comments, I really appreciate it and I try to keep it updated soon possible. About your questions, you don't need viewdidload or viewwillappear specific, you can do it in wherever moment, maybe you can do it in awakeFromNib like override func awakeFromNib() {
super.awakeFromNib()
"yourstring".localized
} or you can create a method and call it in your table view controller, I hope this answer can help you, let me know more comments about that. |
@jrumol some news? |
Hola Andrés, Muchísimas gracias por tu interés. Esta semana he estado muy ocupado y no he tenido tiempo de dedicarle a la aplicación. En cuanto pueda te digo. El problema que se me presenta con respecto a lo que me dices de ponerlo en awakeFromNib es que así se traducen los String que están fuera del tableview, es decir, el título y poca cosa más. Casi todo lo que hay que traducir está dentro de las funciones "cellforrowatindexpath" y en "viewforheaderatindexpath". Y... ¿como le dices que cada vez que aparezca el controlador renueve todos esos valores? Porque la función tableview.reloaddata() no funciona. Perdón por el español... pero viendo tu nombre pensé que me entenderías en español. |
Hi again Andrés, I had an hour to try it with my app and your Pod. One question: I am using Xcode 10 and when I write the "Observer" using the code in the Readme file;
I get an error because the expression "LanguageChangeNotification" doesn't exist. And suggest to fix it with the expression "localizeChangeNotification". I changed it and it worked ok. I added in the Appdelegate -> didFinishLaunchingWithOptions the following line:
Because I have the strings translation in the file Localizable.strings, although I also have a Main.strings file attached to the Main.storyboard. The tableview I am using has static cells, so I insert the headers and the footers for each section in the Main.storyboard, that is also localised. And add the localisation strings to the Main.strings file for each language. This is my code: `import UIKit class SettingsTableViewController: UITableViewController {
}` When changing between Spanish and English, only the view title, the buttons and the labels are changed. However, the section headers and footers doesn't change. The function tableView.reloadData() doesn't work and also tableView.reloadSectionIndexTitles(). |
Hi again, I managed to make it work. The key was to include in the function "translateSettings" the line self.reloadData() The cose is as follows: ` class SettingsTableViewController: UITableViewController {
} However, I still don't know how to translate the tableview with collectionViews embedded. If I put it in "awakeFromNib" it doesn't work. |
@jrumol Hii, yes I speak Spanish also, I'm checking this issue right now, I'll back soon |
@jrumol Hii, thanks for that feedback, yes the documentation is wrong, I updated it and put an example in the example project, the key to listen is localizeChangeNotification, NotificationCenter.default.addObserver(
self,
selector: #selector(localize),
name: NSNotification.Name(localizeChangeNotification),
object: nil
) let me know if it works for you, and yes I speak Spanish :) If you feel better write me in Spanish :) also, Thanks and have a good day |
@jrumol Hii, any update? |
Hi again Andrés, I haven't had enough time to solve the problem. However, I found something. If I write the section headers dinamically in the function viewForHeaderInSection, like this:
It doesn't work and doesn't update unless you restart the App. But if I write the following within viewForHeaderInSection:
It updates everytime I show this view. |
Hi, thanks for your work.
I am trying to translate an app that is built with a tableviewcontroller and each row has a separate tableviewcell file, and each tableviewcell has a collectionviewcell. This is to present a view like NetFlix or the AppStore: collectionviews embedded in tableviews.
The problem with the translation comes when I want to translate in the HomeTableViewController file. Because the strings to translate are in the TableViewCell file, that has no viewdidload or viewwillappear.
Any help would be very much appreciated.
The text was updated successfully, but these errors were encountered: