Remove unused NSBundle extension methods.

Fix compile errors and remove duplicate strings after rebase.
This commit is contained in:
Doug 2022-03-03 09:37:14 +00:00
parent 705b31a302
commit 7ccbdc4efc
9 changed files with 2 additions and 100 deletions

View file

@ -32,9 +32,6 @@ class CommonConfiguration: NSObject, Configurable {
return
}
// Customize the localized string table
Bundle.mxk_customizeLocalizedStringTableName("Vector")
// Disable CallKit
settings.isCallKitEnabled = false

View file

@ -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" = "أنتَ قَد جَعَلتَ الرَّسائِلَ المُستَقبَليَّة مَرئيَّة لِلجَميع، مُنذُ أن تَمَّت دَعوَتُهُم.";

View file

@ -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.
*/

View file

@ -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];

View file

@ -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)
}

View file

@ -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

View file

@ -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

View file

@ -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

1
changelog.d/5325.change Normal file
View file

@ -0,0 +1 @@
Localisation: Merge MatrixKit.strings into Vector.strings and de-dupe.