Skip to content

Commit

Permalink
Merge branch 'release/0.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
ataka committed Jul 23, 2020
2 parents fcddbb3 + a8528f0 commit 50b5907
Show file tree
Hide file tree
Showing 27 changed files with 743 additions and 936 deletions.
96 changes: 96 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

## User settings
xcuserdata/

## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
*.xcscmblueprint
*.xccheckout

## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
build/
DerivedData/
*.moved-aside
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3

## Obj-C/Swift specific
*.hmap

## App packaging
*.ipa
*.dSYM.zip
*.dSYM

## Playgrounds
timeline.xctimeline
playground.xcworkspace

# Swift Package Manager
#
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
# Packages/
# Package.pins
# Package.resolved
*.xcodeproj
#
# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata
# hence it is not needed unless you have added a package configuration file to your project
# .swiftpm

.build/

# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
# Pods/
#
# Add this line if you want to avoid checking in source code from the Xcode workspace
# *.xcworkspace

# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts

Carthage/Build/

# Accio dependency management
Dependencies/
.accio/

# fastlane
#
# It is recommended to not store the screenshots in the git repo.
# Instead, use fastlane to re-generate the screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/#source-control

fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots/**/*.png
fastlane/test_output

# Code Injection
#
# After new code Injection tools there's a generated folder /iOSInjectionProject
# https://github.com/johnno1962/injectionforxcode

iOSInjectionProject/

# Emacs
*~

# Mac
.DS_Store
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2015 Yosuke Ishikawa

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
25 changes: 18 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
DSTROOT=/tmp/ls2xs.dst
.PHONY : compile
compile:
swift build --disable-sandbox -c release

prefix_install:
xcodebuild install -scheme ls2xs DSTROOT=$(DSTROOT)
mkdir -p $(PREFIX)/bin
cp -f $(DSTROOT)/usr/local/bin/ls2xs $(PREFIX)/bin/
.PHONY : prefix_install
prefix_install: compile
sudo mkdir -p $(PREFIX)/bin
sudo cp -p ./.build/release/ls2xs $(PREFIX)/bin

test:
set -o pipefail && xcodebuild test -scheme ls2xs | xcpretty -c -r junit -o build/test-report.xml
.PHONY : xcodeproj
xcodeproj:
swift package generate-xcodeproj

.PHONY : test
# test:
# set -o pipefail && xcodebuild test -scheme ls2xs | xcpretty -c -r junit -o build/test-report.xml

.PHONY : prepare_release
prepare_release:
scripts/prepare_release.sh
16 changes: 16 additions & 0 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"object": {
"pins": [
{
"package": "swift-argument-parser",
"repositoryURL": "https://github.com/apple/swift-argument-parser.git",
"state": {
"branch": null,
"revision": "eb51f949cdd0c9d88abba9ce79d37eb7ea1231d0",
"version": "0.2.0"
}
}
]
},
"version": 1
}
26 changes: 26 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// swift-tools-version:5.2
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "ls2xs",
products: [
.executable(name: "ls2xs", targets: ["ls2xs"])
],
dependencies: [
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "0.2.0"),
],
targets: [
.target(
name: "ls2xs",
dependencies: [.product(name: "ArgumentParser", package: "swift-argument-parser")]),
.testTarget(
name: "ls2xsTests",
dependencies: ["ls2xs"]),
]
)

// Local Variables:
// swift-mode:parenthesized-expression-offset: 4
// End:
56 changes: 42 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,68 @@
# ls2xs

<p>
<a href="https://github.com/ataka/ls2xs/blob/develop/LICENSE">
<img alt="GitHub license" src="https://img.shields.io/github/license/ataka/ls2xs"/>
</a>
<a href="https://docs.swift.org/swift-book/index.html">
<img alt="Swift 5.2" src="https://img.shields.io/badge/Swift-5.2-orange.svg"/>
</a>
<a href="https://github.com/ataka/ls2xs/releases">
<img alt="GitHub release (latest by date)" src="https://img.shields.io/github/v/release/ataka/ls2xs">
</a>
</p>

<!--
[![Circle CI](https://img.shields.io/circleci/project/ishkawa/ls2xs/master.svg?style=flat)](https://circleci.com/gh/ishkawa/ls2xs/tree/master)

-->

A command line tool that updates .strings of .xib and .storyboard using Localizable.strings.

![](http://blog.ishkawa.org/assets/misc/ls2xs.gif)

## Installation

### Brew

```
brew install ishkawa/formulae/ls2xs
$ brew install ataka/formulae/ls2xs
```

### Make

``` shellsession
$ git pull https://github.com/ataka/ls2xs.git
$ cd ls2xs
$ PREFIX=/usr/local make prefix_install
```

## Usage

- Enable base internationalization.
- Add Localizable.strings for each languages.
- Set keys of Localizable.strings to text values in .xib or .storyboard, as you set them to NSLocalizedString("key", "comment") in code.
- Add `Localizable.strings` for each languages.
- Set keys of `Localizable.strings` to text values in .xib or .storyboard, as you set them to `NSLocalizedString(_:comment:)` in code.
- Add "New Run Script Phase" to "Build Phases" of your application target, and set contents:

```shell
/usr/local/bin/ls2xs $TARGET_NAME
/usr/local/bin/ls2xs $TARGET_PATH
```

`ls2xc` generates .strings for .xib and .storyboard using `ibtool --generate-strings-file`.
Then, `ls2xc` replaces value of .strings with value of Localizable.strings if it matches key of Localizable.strings.
Then, `ls2xc` replaces value of .strings with value of `Localizable.strings` if it matches key of `Localizable.strings`.


## Example

Suppose Main.storyboard(Base) has UILabel (Object ID: 4gA-LI-pd8, text: "hello").
Suppose `Base.lproj/Main.storyboard` has `UILabel (Object ID: 4gA-LI-pd8, text: "hello")`.


### Input

- Localizable.strings(en): `"hello" = "Hello";`
- Localizable.strings(ja): `"hello" = "こんにちは";`
- `en.lproj/Localizable.strings`: `"hello" = "Hello";`
- `ja.lproj/Localizable.strings`: `"hello" = "こんにちは";`


### Output

- Main.strings(en): `"4gA-LI-pd8.title" = "Hello";`
- Main.strings(ja): `"4gA-LI-pd8.title" = "こんにちは";`
- `en.lproj/Main.strings`: `"4gA-LI-pd8.title" = "Hello";`
- `ja.lproj/Main.strings`: `"4gA-LI-pd8.title" = "こんにちは";`


## Contributing
Expand All @@ -54,6 +73,11 @@ Please file issues or send pull requests for anything you notice.
- Write tests to prevent making regression.
- Keep in mind we make no primises that your proposal will be accepted.

## Attributions

This tool is powered by:

- [apple/swift\-argument\-parser](https://github.com/apple/swift-argument-parser)

## License

Expand All @@ -64,3 +88,7 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

<!-- Local Variables: -->
<!-- mode: gfm -->
<!-- End: -->
Loading

0 comments on commit 50b5907

Please sign in to comment.