summaryrefslogtreecommitdiffstats
path: root/macosx/HBAudioTransformers.m
diff options
context:
space:
mode:
authorDamiano Galassi <[email protected]>2019-06-07 12:08:00 +0200
committerDamiano Galassi <[email protected]>2019-06-07 12:08:00 +0200
commit9023a245b3b5201fc93bd5616e55c3a4e0287592 (patch)
tree5d1aa2b4d77264b1dc5911feaef2938bc73c2839 /macosx/HBAudioTransformers.m
parent72b57de8eabcc082f1cee715856f8e63dccaeb18 (diff)
MacGui: localize the 'None' item in the fallback encoders popup.
Diffstat (limited to 'macosx/HBAudioTransformers.m')
-rw-r--r--macosx/HBAudioTransformers.m90
1 files changed, 83 insertions, 7 deletions
diff --git a/macosx/HBAudioTransformers.m b/macosx/HBAudioTransformers.m
index 4a4adec09..42d9abccc 100644
--- a/macosx/HBAudioTransformers.m
+++ b/macosx/HBAudioTransformers.m
@@ -1,16 +1,92 @@
-//
-// HBAudioTransformers.m
-// HandBrake
-//
-// Created by Damiano Galassi on 26/08/2016.
-//
-//
+/* HBAudioTransformers.m $
+
+ This file is part of the HandBrake source code.
+ Homepage: <http://handbrake.fr/>.
+ It may be used under the terms of the GNU General Public License. */
#import "HBAudioTransformers.h"
+#import "HBLocalizationUtilities.h"
#include "hb.h"
#pragma mark - Value Trasformers
+@implementation HBFallbackEncodersTransformer
+
++ (Class)transformedValueClass
+{
+ return [NSArray class];
+}
+
+- (id)transformedValue:(id)value
+{
+ if (value != nil)
+ {
+ NSMutableArray *localizedArray = [NSMutableArray array];
+
+ for (NSString *text in value)
+ {
+ if ([text isEqualToString:@"None"])
+ {
+ [localizedArray addObject:HBKitLocalizedString(@"None", @"HBSubtitles -> none track name")];
+ }
+ else
+ {
+ [localizedArray addObject:text];
+ }
+ }
+ return localizedArray;
+ }
+
+ return value;
+}
+
++ (BOOL)allowsReverseTransformation
+{
+ return NO;
+}
+
+@end
+
+@implementation HBFallbackEncoderTransformer
+
++ (Class)transformedValueClass
+{
+ return [NSString class];
+}
+
+- (id)transformedValue:(id)value
+{
+ const char *name = hb_audio_encoder_get_name([value intValue]);
+ if (name)
+ {
+ return @(name);
+ }
+ else
+ {
+ return HBKitLocalizedString(@"None", @"HBSubtitles -> none track name");
+ }
+}
+
++ (BOOL)allowsReverseTransformation
+{
+ return YES;
+}
+
+- (id)reverseTransformedValue:(id)value
+{
+ if ([value isEqualTo:HBKitLocalizedString(@"None", @"HBSubtitles -> none track name")])
+ {
+ return @(hb_audio_encoder_get_from_name("none"));
+ }
+ else
+ {
+ return @(hb_audio_encoder_get_from_name([value UTF8String]));
+ }
+}
+
+@end
+
+
@implementation HBEncoderTransformer
+ (Class)transformedValueClass