Skip to content

Commit

Permalink
Merge pull request #27 from andresilvagomez/fix/string
Browse files Browse the repository at this point in the history
Fix Locale keys only with one string file.
  • Loading branch information
andresilvagomez authored May 15, 2018
2 parents 9e2db95 + 36f30b6 commit 1f0986c
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 6 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,21 @@
All notable changes to this project will be documented in this file.
`Localize` adheres to [Semantic Versioning](http://semver.org/).

## [2.0.3](https://github.com/andresilvagomez/Localize/releases/tag/2.0.3)
Released on 2018-05-15.

#### Added
- Fix localize strings when user only has a one string file.
- By [Andres Silva](https://github.com/andresilvagomez) in Pull Request
[#27](https://github.com/andresilvagomez/Localize/pull/27).

## [2.0.2](https://github.com/andresilvagomez/Localize/releases/tag/2.0.2)
Released on 2018-05-10.

#### Added
- Improve strings with extended languajes like to es-mx for defaults localizations.
- By [Benjamin Erhart](https://github.com/tladesignz) in Pull Request
[#24](https://github.com/andresilvagomez/Localize/pull/25).
[#25](https://github.com/andresilvagomez/Localize/pull/25).

## [2.0.1](https://github.com/andresilvagomez/Localize/releases/tag/2.0.1)
Released on 2018-04-15.
Expand Down
4 changes: 2 additions & 2 deletions Localize.podspec
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Pod::Spec.new do |s|

s.name = "Localize"
s.version = "2.0.2"
s.version = "2.0.3"
s.license = 'MIT'
s.summary = "Localize is a framework writed in swift to localize your projects easier improves i18n, including storyboards and strings."
s.homepage = "https://github.com/andresilvagomez/Localize"
s.author = { "Andres Silva" => "andresilvagomez@gmail.com" }
s.source = { :git => "https://github.com/andresilvagomez/Localize.git", :tag => "2.0.2" }
s.source = { :git => "https://github.com/andresilvagomez/Localize.git", :tag => "2.0.3" }

s.ios.deployment_target = '9.0'
s.source_files = "Source/*.swift"
Expand Down
8 changes: 8 additions & 0 deletions Localize.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
objects = {

/* Begin PBXBuildFile section */
2B41FFEB20AB19570012AF1E /* StringSingleTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B41FFEA20AB19570012AF1E /* StringSingleTest.swift */; };
2B41FFEC20AB1A450012AF1E /* OnlyOneLang.strings in Resources */ = {isa = PBXBuildFile; fileRef = 2B41FFE820AB18FE0012AF1E /* OnlyOneLang.strings */; };
2B717465207D9AFE0070DC5F /* LocalizeUI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B717464207D9AFE0070DC5F /* LocalizeUI.swift */; };
2B717469207DC6E00070DC5F /* UIViewComponents.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B717468207DC6E00070DC5F /* UIViewComponents.swift */; };
2B931AA8208302FB00C26D6B /* lang-en.json in Resources */ = {isa = PBXBuildFile; fileRef = 9F761AEB1E3063E400904B4B /* lang-en.json */; };
Expand Down Expand Up @@ -56,6 +58,8 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
2B41FFE820AB18FE0012AF1E /* OnlyOneLang.strings */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; path = OnlyOneLang.strings; sourceTree = "<group>"; };
2B41FFEA20AB19570012AF1E /* StringSingleTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StringSingleTest.swift; sourceTree = "<group>"; };
2B717464207D9AFE0070DC5F /* LocalizeUI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalizeUI.swift; sourceTree = "<group>"; };
2B717468207DC6E00070DC5F /* UIViewComponents.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIViewComponents.swift; sourceTree = "<group>"; };
2B80F11B20830FBD00542924 /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/Storyboard.strings; sourceTree = "<group>"; };
Expand Down Expand Up @@ -176,6 +180,7 @@
9FA3BC501E318C080054CA92 /* ReadingOtherFiles.swift */,
2BD8531820812DD900FB0E53 /* StringBadSources.swift */,
9F19DFC61E4D2B1D00F953E6 /* StringBaseTest.swift */,
2B41FFEA20AB19570012AF1E /* StringSingleTest.swift */,
9F1678001E51F33E0022F3F8 /* StringBaseTestInSpanish.swift */,
9FCD8EA41E52AD3E00B5909C /* StringsChanginDefaultFileName.swift */,
2B717468207DC6E00070DC5F /* UIViewComponents.swift */,
Expand All @@ -202,6 +207,7 @@
9F1677FC1E51DE270022F3F8 /* Strings.strings */,
9FCD8EA21E52A9D800B5909C /* Other.strings */,
2BD85322208130A100FB0E53 /* Storyboard.storyboard */,
2B41FFE820AB18FE0012AF1E /* OnlyOneLang.strings */,
);
name = "Supporting Files";
sourceTree = "<group>";
Expand Down Expand Up @@ -316,6 +322,7 @@
2B931AAD2083031000C26D6B /* some-it.json in Resources */,
2B931AB02083031700C26D6B /* Strings.strings in Resources */,
2B931AAE2083031000C26D6B /* file-de.json in Resources */,
2B41FFEC20AB1A450012AF1E /* OnlyOneLang.strings in Resources */,
2B931AAC2083031000C26D6B /* other-es.json in Resources */,
2B931AB12083031700C26D6B /* Other.strings in Resources */,
2B931AA8208302FB00C26D6B /* lang-en.json in Resources */,
Expand Down Expand Up @@ -349,6 +356,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
2B41FFEB20AB19570012AF1E /* StringSingleTest.swift in Sources */,
2B717469207DC6E00070DC5F /* UIViewComponents.swift in Sources */,
9F1678011E51F33E0022F3F8 /* StringBaseTestInSpanish.swift in Sources */,
9F989F4C1E2B3B8200A19F67 /* BaseTest.swift in Sources */,
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ platform :ios, '9.0'
use_frameworks!

target '<Your Target Name>' do
pod 'Localize' , '~> 2.0.2'
pod 'Localize' , '~> 2.0.3'
end
```

Expand Down
8 changes: 8 additions & 0 deletions Source/LocalizeStrings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ class LocalizeStrings: LocalizeCommonProtocol {
return localized
}
}

if bundle.path(forResource: tableName, ofType: "strings") != nil {
let localized = bundle.localizedString(forKey: key, value: nil, table: tableName)

if localized != key {
return localized
}
}

return nil
}
Expand Down
1 change: 1 addition & 0 deletions Tests/OnlyOneLang.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"hello.world.for.all" = "Hello world for all";
2 changes: 0 additions & 2 deletions Tests/StringBaseTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import XCTest
import Localize

class StringBaseTest: XCTestCase {

override func setUp() {
super.setUp()
Localize.update(provider: .strings)
Expand Down Expand Up @@ -61,5 +60,4 @@ class StringBaseTest: XCTestCase {
let language = Localize.currentLanguage
XCTAssertTrue(language == "en")
}

}
29 changes: 29 additions & 0 deletions Tests/StringSingleTest.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// StringSingleTest.swift
// LocalizeTests
//
// Created by Andres Silva Gomez on 5/15/18.
// Copyright © 2018 Kekiiwaa. All rights reserved.
//

import XCTest
import Localize

class StringSingleTest: XCTestCase {
override func setUp() {
super.setUp()
Localize.update(provider: .strings)
Localize.update(bundle: Bundle(for: type(of: self)))
Localize.update(fileName: "OnlyOneLang")
}

func testLocalizeInSingleStringFile() {
let localized = "hello.world.for.all".localized
XCTAssertTrue(localized == "Hello world for all")
}

func testLocalizeInSingleStringFileNil() {
let localized = "hello.world.for.allll".localized
XCTAssertTrue(localized == "hello.world.for.allll")
}
}

0 comments on commit 1f0986c

Please sign in to comment.