diff --git a/FireworkVideoUI.podspec b/FireworkVideoUI.podspec index 0e20e2f..8fbf8dd 100644 --- a/FireworkVideoUI.podspec +++ b/FireworkVideoUI.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'FireworkVideoUI' - s.version = '0.1.0' + s.version = '0.1.1' s.summary = 'An extension library meant to provide easier interfaces for the FireworkVideoSDK.' s.homepage = 'https://github.com/loopsocial/firework_ios_sdk_ui_extensions' s.license = 'Apache License, Version 2.0' diff --git a/Sources/FireworkVideoUI/AppLanguage/AppLanguageManager.swift b/Sources/FireworkVideoUI/AppLanguage/AppLanguageManager.swift index 89cac35..394235d 100644 --- a/Sources/FireworkVideoUI/AppLanguage/AppLanguageManager.swift +++ b/Sources/FireworkVideoUI/AppLanguage/AppLanguageManager.swift @@ -110,6 +110,7 @@ public class AppLanguageManager { UITextView.swizzleTextViewMethodsForAppLanguage() UIWindow.swizzleWindowMethodsForAppLanguage() UIView.swizzleViewMethodsForAppLanguage() + NSLocale.swizzleNSLocaleMethodsForAppLanguage() } LayoutFlipManager.swizzelMethods() diff --git a/Sources/FireworkVideoUI/AppLanguage/Extensions/Foundation/NSLocale+AppLanguage.swift b/Sources/FireworkVideoUI/AppLanguage/Extensions/Foundation/NSLocale+AppLanguage.swift new file mode 100644 index 0000000..82f83a2 --- /dev/null +++ b/Sources/FireworkVideoUI/AppLanguage/Extensions/Foundation/NSLocale+AppLanguage.swift @@ -0,0 +1,24 @@ +// +// Locale+AppLanguage.swift +// +// Created by linjie jiang on 5/7/24. +// + +import Foundation + +extension NSLocale { + static func swizzleNSLocaleMethodsForAppLanguage() { + Swizzle.swizzleClassSelector( + cls: self, + originalSelector: #selector(getter: NSLocale.current), + customSelector: #selector(NSLocale.fw_current)) + } + + @objc static func fw_current() -> Locale { + if let language = AppLanguageManager.shared.appLanguage { + return Locale(identifier: language) + } + + return fw_current() + } +}