This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if which $PODS_ROOT/SwiftGen/bin/swiftgen >/dev/null; then | |
SRCDIR="$PROJECT_DIR/$TARGET_NAME" | |
$PODS_ROOT/SwiftGen/bin/swiftgen strings "$SRCDIR/Resources/Base.lproj/Localizable.strings" --output "$SRCDIR/Code/Constants/SwiftGen/Strings.swift" --templatePath "$PROJECT_DIR/../../Resources/Localization/localize-flat-swift4.stencil" | |
$PROJECT_DIR/../../scripts/L10nPlurals.swift --input "$PROJECT_DIR/Localization/Resources" --output "$PROJECT_DIR/Localization/Code/L10nPlurals.swift" -public | |
else | |
echo "warning: SwiftGen not installed, download it from https://github.com/AliSoftware/SwiftGen" | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env xcrun --sdk macosx swift | |
import Foundation | |
enum PathExtension: String { | |
case lproj | |
case stringsdict | |
} | |
// MARK: Arguments |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//swiftlint:disable identifier_name | |
public extension L10n { | |
public struct Plurals { | |
/// 1 alerte | |
/// 2 alertes | |
public static func alertsTitle(_ p1: Int) -> String { | |
return L10n.trPlurals("alerts_titles", count: p1) | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/swift | |
import Foundation | |
var baseLanguage = "fr" | |
var managedLanguages = ["fr": "🇫🇷"] | |
let languageFolderPath = "AppFrameworks/Localization/Localization/Resources" | |
guard CommandLine.arguments.count > 2 else { | |
print("❌ - No argument received, please put the Lokalise [1:Project ID] and your [2:API Token] as args") | |
exit(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
guard CommandLine.arguments.count > 2 else { | |
exit(1) | |
} | |
let lokaliseProjectId = CommandLine.arguments[1] | |
let lokaliseApiToken = CommandLine.arguments[2] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func copyLokalizableStrings() { | |
managedLanguages.forEach { (key, value) in | |
if key == baseLanguage { | |
bash(command: "cp", arguments: ["./\(key).lproj/Localizable.strings", "../\(languageFolderPath)/Base.lproj/"]) | |
bash(command: "cp", arguments: ["./\(key).lproj/Localizable.stringsdict", "../\(languageFolderPath)/Base.lproj/"]) | |
} else { | |
bash(command: "cp", arguments: ["./\(key).lproj/Localizable.strings", "../\(languageFolderPath)/\(key).lproj/"]) | |
bash(command: "cp", arguments: ["./\(key).lproj/Localizable.stringsdict", "../\(languageFolderPath)/\(key).lproj/"]) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func unzip(archive archiveName: String) { | |
bash(command: "unzip", arguments: [archiveName]) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func writeData(_ data: Data?, archiveName: String) { | |
guard let data = data else { | |
return | |
} | |
do { | |
let current = FileManager.default.currentDirectoryPath | |
let url = URL(string: "file://\(current)")! | |
let fileURL = url.appendingPathComponent("\(archiveName).zip") | |
try data.write(to: fileURL) | |
} catch { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var baseLanguage = "fr" | |
var managedLanguages = ["fr": "🇫🇷"] | |
let languageFolderPath = "AppFrameworks/Localization/Localization/Resources" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func downloadLastLokaliseStrings() { | |
let lokaliseTask = urlSession.dataTask(with: lokaliseRequest) { (data, response, error) in | |
if let error = error { | |
// manage error | |
} else { | |
guard let data = data else { | |
// be sure to have data | |
return | |
} | |
do { |
NewerOlder