From 7ccbdc4efcd5ec11d1e027b63ee32d1a9a2a816a Mon Sep 17 00:00:00 2001 From: Doug Date: Thu, 3 Mar 2022 09:37:14 +0000 Subject: [PATCH] Remove unused NSBundle extension methods. Fix compile errors and remove duplicate strings after rebase. --- Config/CommonConfiguration.swift | 3 - Riot/Assets/ar.lproj/Vector.strings | 2 - .../MatrixKit/Categories/NSBundle+MatrixKit.h | 16 ---- .../MatrixKit/Categories/NSBundle+MatrixKit.m | 75 ------------------- ...erviceTermsModalScreenViewController.swift | 2 +- RiotNSE/target.yml | 1 - RiotShareExtension/target.yml | 1 - SiriIntents/target.yml | 1 - changelog.d/5325.change | 1 + 9 files changed, 2 insertions(+), 100 deletions(-) create mode 100644 changelog.d/5325.change diff --git a/Config/CommonConfiguration.swift b/Config/CommonConfiguration.swift index 9567a696d..5802f8d77 100644 --- a/Config/CommonConfiguration.swift +++ b/Config/CommonConfiguration.swift @@ -32,9 +32,6 @@ class CommonConfiguration: NSObject, Configurable { return } - // Customize the localized string table - Bundle.mxk_customizeLocalizedStringTableName("Vector") - // Disable CallKit settings.isCallKitEnabled = false diff --git a/Riot/Assets/ar.lproj/Vector.strings b/Riot/Assets/ar.lproj/Vector.strings index 927e7e8dc..835a0195e 100644 --- a/Riot/Assets/ar.lproj/Vector.strings +++ b/Riot/Assets/ar.lproj/Vector.strings @@ -802,7 +802,6 @@ // room info dialog Screen // room details dialog screen -"room_details_title" = "تَفاصيلُ الغُرفَة"; "login_error_must_start_http" = "عُنوانُ URL يَجِبُ أن يَبدَأ بِبروتوكل //:[s]http"; // Login Screen @@ -850,7 +849,6 @@ // titles // button names -"ok" = "حَسَناً"; "notice_room_history_visible_to_members_from_joined_point_by_you_for_dm" = "أنتَ قَد جَعَلتَ الرَّسائِلَ المُستَقبَليَّة مَرئيَّة لِلجَميع، مُنذُ أنِ اِنضَمُّوا."; "notice_room_history_visible_to_members_from_joined_point_by_you" = "أنتَ قَد جَعَلتَ تَأريخَ الغُرفَةِ المُستَقبَليّ مَرئيٌّ لِجَميعِ أعضاءِ الغُرفَة، مِن النُّقطَة الَّتي اِنضَمُّوا فِيهَا."; "notice_room_history_visible_to_members_from_invited_point_by_you_for_dm" = "أنتَ قَد جَعَلتَ الرَّسائِلَ المُستَقبَليَّة مَرئيَّة لِلجَميع، مُنذُ أن تَمَّت دَعوَتُهُم."; diff --git a/Riot/Modules/MatrixKit/Categories/NSBundle+MatrixKit.h b/Riot/Modules/MatrixKit/Categories/NSBundle+MatrixKit.h index 9bcc5572a..7b3e36ab3 100644 --- a/Riot/Modules/MatrixKit/Categories/NSBundle+MatrixKit.h +++ b/Riot/Modules/MatrixKit/Categories/NSBundle+MatrixKit.h @@ -37,22 +37,6 @@ */ + (NSURL *)mxk_audioURLFromMXKAssetsBundleWithName:(NSString *)name; -/** - Customize the table used to retrieve the localized version of a string during [mxk_localizedStringForKey:] call. - If the key is not defined in this table, the localized string is retrieved from the default table "MatrixKit.strings". - - @param tableName the name of the table containing the key-value pairs. Also, the suffix for the strings file (a file with the .strings extension) to store the localized string. - */ -+ (void)mxk_customizeLocalizedStringTableName:(NSString*)tableName; - -/** - Retrieve localized string from the customized table. If none, MatrixKit Assets bundle is used. - - @param key The string key. - @return The localized string. - */ -+ (NSString *)mxk_localizedStringForKey:(NSString *)key; - /** An AppExtension-compatible wrapper for bundleForClass. */ diff --git a/Riot/Modules/MatrixKit/Categories/NSBundle+MatrixKit.m b/Riot/Modules/MatrixKit/Categories/NSBundle+MatrixKit.m index 70a75a59b..599252032 100644 --- a/Riot/Modules/MatrixKit/Categories/NSBundle+MatrixKit.m +++ b/Riot/Modules/MatrixKit/Categories/NSBundle+MatrixKit.m @@ -20,8 +20,6 @@ @implementation NSBundle (MatrixKit) -static NSString *customLocalizedStringTableName = nil; - + (NSBundle*)mxk_assetsBundle { // Get the bundle within MatrixKit @@ -31,35 +29,6 @@ static NSString *customLocalizedStringTableName = nil; return [NSBundle bundleWithURL:assetsBundleURL]; } -+ (NSBundle*)mxk_languageBundle -{ - NSString *language = [NSBundle mxk_language]; - NSBundle *bundle = [NSBundle mxk_assetsBundle]; - - // If there is a runtime language (different from the legacy language chose by the OS), - // return the sub bundle for this language - if (language) - { - bundle = [NSBundle bundleWithPath:[bundle pathForResource:[NSBundle mxk_language] ofType:@"lproj"]]; - } - - return bundle; -} - -+ (NSBundle*)mxk_fallbackLanguageBundle -{ - NSString *fallbackLanguage = [NSBundle mxk_fallbackLanguage]; - NSBundle *bundle = [NSBundle mxk_assetsBundle]; - - // Return the sub bundle of the fallback language if any - if (fallbackLanguage) - { - bundle = [NSBundle bundleWithPath:[bundle pathForResource:fallbackLanguage ofType:@"lproj"]]; - } - - return bundle; -} - // use a cache to avoid loading images from file system. // It often triggers an UI lag. static MXLRUCache *imagesResourceCache = nil; @@ -92,50 +61,6 @@ static MXLRUCache *imagesResourceCache = nil; return [NSURL fileURLWithPath:[[NSBundle mxk_assetsBundle] pathForResource:name ofType:@"mp3" inDirectory:@"Sounds"]]; } -+ (void)mxk_customizeLocalizedStringTableName:(NSString*)tableName -{ - customLocalizedStringTableName = tableName; -} - -+ (NSString *)mxk_localizedStringForKey:(NSString *)key -{ - NSString *localizedString; - - // Check first customized table - // Use "_", a string that does not worth to be translated, as default value to mark - // a key that does not have a value in the customized table. - if (customLocalizedStringTableName) - { - localizedString = NSLocalizedStringWithDefaultValue(key, customLocalizedStringTableName, [NSBundle mainBundle], @"_", nil); - } - - if (!localizedString || (localizedString.length == 1 && [localizedString isEqualToString:@"_"])) - { - // Check if we need to manage a fallback language - // as we do in NSBundle+MXKLanguage - NSString *language = [NSBundle mxk_language]; - NSString *fallbackLanguage = [NSBundle mxk_fallbackLanguage]; - - BOOL manageFallbackLanguage = fallbackLanguage && ![fallbackLanguage isEqualToString:language]; - - localizedString = NSLocalizedStringWithDefaultValue(key, @"MatrixKit", - [NSBundle mxk_languageBundle], - manageFallbackLanguage ? @"_" : nil, - nil); - - if (manageFallbackLanguage - && (!localizedString || (localizedString.length == 1 && [localizedString isEqualToString:@"_"]))) - { - // The translation is not available, use the fallback language - localizedString = NSLocalizedStringFromTableInBundle(key, @"MatrixKit", - [NSBundle mxk_fallbackLanguageBundle], - nil); - } - } - - return localizedString; -} - + (NSBundle *)mxk_bundleForClass:(Class)aClass { NSBundle *bundle = [NSBundle bundleForClass:aClass]; diff --git a/Riot/Modules/ServiceTerms/Modal/Modal/ServiceTermsModalScreenViewController.swift b/Riot/Modules/ServiceTerms/Modal/Modal/ServiceTermsModalScreenViewController.swift index a1bbb053b..316242432 100644 --- a/Riot/Modules/ServiceTerms/Modal/Modal/ServiceTermsModalScreenViewController.swift +++ b/Riot/Modules/ServiceTerms/Modal/Modal/ServiceTermsModalScreenViewController.swift @@ -313,7 +313,7 @@ extension ServiceTermsModalScreenViewController: ServiceTermsModalTableHeaderVie } let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert) - alertController.addAction(UIAlertAction(title: Bundle.mxk_localizedString(forKey: "ok"), style: .default)) + alertController.addAction(UIAlertAction(title: VectorL10n.ok, style: .default)) present(alertController, animated: true) } diff --git a/RiotNSE/target.yml b/RiotNSE/target.yml index 77e72852f..644b91c84 100644 --- a/RiotNSE/target.yml +++ b/RiotNSE/target.yml @@ -67,5 +67,4 @@ targets: - path: ../Riot/Managers/AppInfo/ excludes: - "**/*.md" # excludes all files with the .md extension - - path: ../Riot/Generated/MatrixKitStrings.swift - path: ../Riot/Modules/Room/TimelineCells/Styles/RoomTimelineStyleIdentifier.swift diff --git a/RiotShareExtension/target.yml b/RiotShareExtension/target.yml index 44ebc5312..29813f2d1 100644 --- a/RiotShareExtension/target.yml +++ b/RiotShareExtension/target.yml @@ -74,5 +74,4 @@ targets: - path: ../Riot/Managers/UserSessions excludes: - "**/*.md" # excludes all files with the .md extension - - path: ../Riot/Generated/MatrixKitStrings.swift - path: ../Riot/Modules/Room/TimelineCells/Styles/RoomTimelineStyleIdentifier.swift diff --git a/SiriIntents/target.yml b/SiriIntents/target.yml index a048b5c46..e08667db3 100644 --- a/SiriIntents/target.yml +++ b/SiriIntents/target.yml @@ -58,5 +58,4 @@ targets: - path: ../Riot/Generated/Strings.swift excludes: - "**/*.md" # excludes all files with the .md extension - - path: ../Riot/Generated/MatrixKitStrings.swift - path: ../Riot/Modules/Room/TimelineCells/Styles/RoomTimelineStyleIdentifier.swift diff --git a/changelog.d/5325.change b/changelog.d/5325.change new file mode 100644 index 000000000..a26d5283b --- /dev/null +++ b/changelog.d/5325.change @@ -0,0 +1 @@ +Localisation: Merge MatrixKit.strings into Vector.strings and de-dupe. \ No newline at end of file