-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Update the WPCom Language Database #24973
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
Conversation
Generated by 🚫 Danger |
|
| App Name | WordPress | |
| Configuration | Release-Alpha | |
| Build Number | 29687 | |
| Version | PR #24973 | |
| Bundle ID | org.wordpress.alpha | |
| Commit | 3e5717c | |
| Installation URL | 0sv6397l9rrc8 |
|
| App Name | Jetpack | |
| Configuration | Release-Alpha | |
| Build Number | 29687 | |
| Version | PR #24973 | |
| Bundle ID | com.jetpack.alpha | |
| Commit | 3e5717c | |
| Installation URL | 1j8fvt3ekqso8 |
c884d4e to
f458626
Compare
|
Hey, looks like this PR has changes from #24972. Does it need a different target branch? |
f458626 to
c3c3b97
Compare
Should be sorted! |
| // Parse the json file | ||
| let path = Bundle.wordPressSharedBundle.path(forResource: "Languages", ofType: "json") | ||
| let data = try! Data(contentsOf: URL(fileURLWithPath: path!)) | ||
| let bundle = try! JSONDecoder().decode(WPComLanguageBundle.self, from: data) |
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.
The languages are hard-coded anyway. I wonder if it'd be simpler to just hard-code with instances, instead of reading and parsing a JSON file:
struct {
let popular: [Language] = [
Language(...)
]
...
}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.
I agree 😄
| /// This helper class allows us to map WordPress.com LanguageID's into human readable language strings. | ||
| /// | ||
| public class WordPressComLanguageDatabase: NSObject { | ||
| public struct WordPressComLanguageDatabase { |
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.
I was confused by this type for a bit, because there is another one with the same name in WordPressKit: https://github.com/wordpress-mobile/WordPress-iOS/blob/fd99f270ff1c1c8015128567e45441c0ee018de4/Modules/Sources/WordPressKit/WordPressComLanguageDatabase.swift
Maybe we should delete one of these?
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.
Nice thanks! Done now.
|





Description
Cleans up the
WordPressComLanguageDatabaseobject to:Languages.jsonfile is correct (and avoid repeatedly parsing it)Codable.Testing instructions
The existing tests pass, so this should be low-risk.