Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 2.0.1 #61

Merged
merged 2 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,13 @@ array.
or empty source string keys.
- `pushTranslations()` now accepts a configuration object that holds any extra
options that might need to be set during the push logic.

## Transifex iOS SDK 2.0.1

*September 21, 2023*

- Addresses language tag discrepancy: The fallback mechanism for accessing the
bundled source locale translations, in case the target translations was not
found, was trying to access the file by using the format that Transifex uses
(e.g. `en_US`) instead of the one that iOS and Xcode use (e.g. `en-US`). The
logic now normalizes the locale name to match the format that iOS accepts.
14 changes: 11 additions & 3 deletions Sources/Transifex/Core.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,21 @@ public enum TXRenderingStategy : Int {
/// is about to be called.
final class BypassLocalizer {
let bundle : Bundle?


private static let IOS_LANGUAGE_TAG_DELIMITER = "-"
private static let TRANSIFEX_LANGUAGE_TAG_DELIMITER = "_"

/// Initializes bypass localizer with a certain locale.
///
/// - Parameter localeCode: The locale to be used
init(with localeCode: String) {
/// Ensure that the bundled localized project container will be accessible for the provided locale,
/// as the iOS uses a hyphen for the language tag (e.g. en-GB) while Transifex uses an
/// underscore (e.g. en_GB).
let normalizedLocaleCode = localeCode.replacingOccurrences(of: Self.TRANSIFEX_LANGUAGE_TAG_DELIMITER,
with: Self.IOS_LANGUAGE_TAG_DELIMITER)
/// Get the bundle for the provided locale code, if it exists.
guard let bundlePath = Bundle.main.path(forResource: localeCode,
guard let bundlePath = Bundle.main.path(forResource: normalizedLocaleCode,
ofType: "lproj") else {
self.bundle = nil
return
Expand Down Expand Up @@ -353,7 +361,7 @@ render '\(stringToRender)' locale code: \(localeCode) params: \(params). Error:
/// A static class that is the main point of entry for all the functionality of Transifex Native throughout the SDK.
public final class TXNative : NSObject {
/// The SDK version
internal static let version = "2.0.0"
internal static let version = "2.0.1"

/// The filename of the file that holds the translated strings and it's bundled inside the app.
public static let STRINGS_FILENAME = "txstrings.json"
Expand Down