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 2aec883095
commit ec8e5e3c19
9 changed files with 2 additions and 100 deletions
@@ -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.
*/
@@ -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];