-
-
Notifications
You must be signed in to change notification settings - Fork 186
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
Add German Localization #68 #92
Conversation
Wow this is a great effort! So one comment, every string that is used in a Text in the end (so text passed in a function that end up in a Text) don't need to be wrapped in |
Yeah I noticed that and already did corrected it last night but maybe I missed some. I‘m pissed that the localization file export doesn’t get the strings that are not in |
Update master
This is a good start, but ideally you should try switching as many string types to LocalizedStringKey, then you can drop most of the NSLocalizedString calls. |
I did some research (and testing): If you pass the text via text: "xyz" to a function where it will be filled into a text object with text(text) the localization doesn't work. Then you have to declare it like @ericlewis thank you, I'll take a look on LocalizedStringKey |
@TheVaan the reason is because any function passing a “string” to Text should actually have LocalizedStringKey as its type for the variable / arg passed, not String. Basically: // Bad, localization won’t work automatically // good, SwiftUI automagically looks up translation Edit: String & LocalizedStringKey aren’t exactly interchangeable, which is something important to keep in mind. If you need to compose Strings, you would still want to use NSLocalizedString. Also, if you do start changing call-sites to LocalizedStringKey you will likely need to change it elsewhere too, since strings aren’t interchangeable. This is good because it will make it obvious which things need translation as well. |
I updated my branch from master (what a disaster, so many changes) so I stumbled across the new todayDashboard and the new sections. struct SectionHeaderView: View {
let text: String
var icon: String?
init(text: String, icon: String? = nil) {
self.text = text
self.icon = icon
}
var body: some View {
HStack(spacing: 6) {
// ...
Text(LocalizedStringKey(text))
.font(.system(.subheadline, design: .rounded))
.fontWeight(.bold)
.foregroundColor(.acHeaderText)
}
// ...
}
} Yeay or neay? Edit: this could have saved me so much time this night... now removing all NSLocaliationString's from SectionHeaderView.... |
@TheVaan if it is completely unavoidable then sure, but try to minimize any direct usage of LocalizedStringKey initializers as much as possible (similar to NSLocalizedString). I can help you figure out how to remove them once you are done. |
@TheVaan oh, another option to fix what you pointed out about Hashable would be to make LocalizedStringKey conform to Hashable. I’m not sure how possible that is, but it could be an option. |
@ericlewis yeah, I thought about extending LocalizedStringKey with Hash, but I seems to be not so easy for an amateur. I think I didn't understand exactly how to reduce the direct usage of the initializer without messing the code up with extra lines of text. Or is this the right way and a better code style then inline text? |
@TheVaan do you mean the code in the PR as it stands? If you’re done I am happy to review. |
@ericlewis There are missing many strings as it is a huge amount... copy and paste the strings isn't that quickly. Currently (full) translated: about, settings, ac helper+ info and the tabbar |
@TheVaan ping me when you’re ready for review, concerting this to a draft for now. |
- more text strings added to english localization - translated Dashboard, Settings, AC Helper+, About to German - modified a few helper classes for localization support (needs review!) - changed DateFormatter to localizable date formats
- sorted entries of Subscribe-, About- and SettingsView - removed obsolet entries
This comment has been minimized.
This comment has been minimized.
@TheVaan I moved your TODO to the description so we can see the progress easier. |
This is really awesome and will speed up localization of the UI for the other language (like French that I'll do) so much. Will look for the actual data a bit later :) |
- Tabbar: changed My Stuff to Collection - CollectionView: changed name to "Collection" (same name as in tab bar) - translated UserListView and CollectionView
I have a problem in CollectionListView.swift line 93: because the selected tab name is |
So for that you'll need to add the whole enum values as keys
so in your localization file you'll have and
I think it should work. |
This is what I tried yesterday but it didn't work. private var emptyView: some View {
let tabName = NSLocalizedString(selectedTab.rawValue, comment: "")
return Text("When you'll stars some \(tabName), they'll be displayed here.")
.foregroundColor(.acSecondaryText)
} |
okay, only SearchView has text inside that needs to translate... thank you for already making it LocalizedStringKey <3
Quick comment: somehow you added back the whole views/dashboard group to your project. This should be completely gone. So you can safely remove dashboards folder from your Xcode and all source inside (not only references but files). |
Oh damn, I think that happened due to the merge conflict yesterday... folder will be removed in the next commit. Thank you! |
… but strings are there)
public func label() -> String { | ||
switch self { | ||
case .fish: | ||
return "Fishes" | ||
case .wallMounted: | ||
return "Wall mounted" | ||
case .nookmiles: | ||
return "Nook Miles" | ||
default: | ||
return self.rawValue.capitalized | ||
} | ||
public func label() -> LocalizedStringKey { | ||
return LocalizedStringKey(self.rawValue) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replaced label() function because using rawValue as LocalizedStringKey makes this obsolet to transform value to readable label.
@ericlewis @Dimillian Okay, I'm done. Have fun 😅 |
Description
This PR is just to let you know there is something going on.
And to get comments: good way / bad way? ideas?
Pull requests with improvements or further translations (more languages) to my forks branch are welcome.
If you like the way I will continue building up the translation file for english and german and modifying the code where needed.
I don't know why there are 3 commits in this branch - all stuff is in
8392b7b
But it is way too late (or too early?) to think about git logic... 😴
Progress
Translate to German state: