marmelroy / localize-swift Goto Github PK
View Code? Open in Web Editor NEWSwift friendly localization and i18n with in-app language switching
License: MIT License
Swift friendly localization and i18n with in-app language switching
License: MIT License
Hello!
I installed by cocoapods,
this is my code:
let langs = ["kk", "ru", "en"]
if i > 0 && i < langs.count {
Localize.setCurrentLanguage(langs[i])
let langStr = Locale.current.languageCode
print("yazik: \(langStr)")
and it is prints: only English, whenever I set other language:(
many thanks @marmelroy , you are anesowe!
How i can update language all view ?
How to change custom font based on language that i changed?
Adding Custom Font Support is appreciated.
".".localized
".".localized.comment(".")
".".localizedFormat(arg1, "arg2", 3)
".".localizedFormat(arg1, "arg2", 3).comment(".")
".".localizedPlural("s")
".".localizedPlural("s").comment(".*")
What do you think about:
I see the current version is 1.5 but readme writes 1.1, do you mind updating it? Or is there a reason why we might want to use 1.1?
Thanks.
var dateFormatter = NSDateFormatter() override func viewDidLoad() { super.viewDidLoad() dateFormatter.dateStyle = .MediumStyle let timeString = "\(dateFormatter.stringFromDate(NSDate()))" dateLbl.text = timeString print(timeString) }
Hi Roy, how can I Localized a date? Is it possible?
Thank you very much!
Hello there,
Is there an older version or branch that supports Swift 2.2?
There is no support for right to left layouts like Arabic Language
it would be great if integrate with https://github.com/Flinesoft/BartyCrouch
to generate the Localize.string File
or Creating a run script to update Localize.string File Automatic
Hi Roy :)
How can I localized this?
let name = NSUserDefaults.standardUserDefaults().valueForKey("name") as! String
searchBar.placeholder = "Hey, \(name) how can we help you?"
the name change depend on which user is currently logged in.
Btw thank you very much!
I finally got Localize-Swift imported and "working" but my app now loads in French rather than the base or English.
Also, I have a button to toggle the language and reload a localized PList but it's not working. What steps do I need to take to make the toggle reload the PList in different languages?
Thanks!
Hi, is there Carthage support for xCode8+Swift2.3? At the moment I can't move straight to Swift3 because some other frameworks that I'm using are not updated.
Hello guys, I am facing an issue with the storyboard files.
They don't get localized? Am I doing something wrong, or is this feature not possible?
I tried this library for in-app localization. In case the device language is english, this library works fine. But in case the device language is arabic, the views automatically use right to left orientation which distort the UI.
how can I use provided genstrings.py file to incremental update Localizable.string file?
Hello,
is there a way to include the content of Localizable.strings in xCode's exported for translation .xliff files?
At the moment, it doesn't work because xcode searches for NSLocalizedString in code, not for actual content in Localizable.strings
If you have any thought, it will be much appreciated.
Thanks
hi @marmelroy ,
Thank you for your awesome work, I am currently using it in my own project.
Is there any possible add some comments when using localized() method.
I think this could be an important option for those with similar text but different meaning on context.
Thanks!
I would like to use the framework, but even following all the instructions I am still unable to build my app because of the No such module 'Localize_Swift' error. I did my research and tried the most common solutions for when a module is not found and none of them worked.
I have downloaded your example app fro GitHub and I am getting the same error when trying to build the app, which makes me think there is probably something broken or missing in the framework itself. Are you aware of any issue using the framework with Xcode 8 and Swift 3?
Would be great if it could work on Apple Watch (:
Running genstrings.py
currently searches all directories, including Examples in the Carthage Checkouts folder. For instance, I get this output:
/*
* ./Carthage/Checkouts/Localize-Swift/examples/LanguageSwitch/Sample/ViewController.swift
*/
"Hello world" = "Hello world";
"Change" = "Change";
"Reset" = "Reset";
It would be helpful to have an --ignore
option to ignore certain directories.
Base localization is English, added a new localization in Korean.
NSBundle.mainBundle().localizations
returns ["Base", "ko", "en"]
Localize.currentLanguage()
returns "en" instead of "Base" and since en.lproj
doesn't exist localization string for English is not showing.
func localized() -> String {
if let path = NSBundle.mainBundle().pathForResource(Localize.currentLanguage(), ofType: "lproj"), bundle = NSBundle(path: path) {
return bundle.localizedStringForKey(self, value: nil, table: nil)
}
return self
}
Having tried all day, I cannot get Localize-Swift to work in UITests. Apparently this could have something to do with the wrong bundle being used.
(lldb) po NSLocalizedString("PASSWORD", comment: "")
"PASSWORD"
(lldb) po NSLocalizedString("PASSWORD", bundle: NSBundle(path: NSBundle(forClass: CaribooUITests.self).pathForResource("en", ofType: "lproj")!)!, comment: "")
"Password"
(lldb) po "PASSWORD".localized()
"PASSWORD"
I have no idea how to implement this and would appreciate help !
I found if I add "Chinese(traditional)" into CFBundleLocalizations,
Localize.availableLanguages() will return
["zh_TW", "de", "en", "es", "fr", "he", "it", "ja", "zh-Hans", "zh-Hant"]
without CFBundleLocalizations will return
["de", "en", "es", "fr", "he", "it", "ja", "zh-Hans", "zh-Hant"]
zh_TW is same as zh-Hant but project doesn't have zh_TW.lproj,
so "Localize" always use defaultLanguage()
.
My project is mixing between swift and objective-c.
I can't find the instruction to use with objective-c view controller.
Hi,
Do you want to fix the warnings and errors with Swift 2.0 Xcode 7?
Hi Guys it's not a issue it's just I can't understand how to implement it.
I have this code:
@IBOutlet weak var CCountry: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
CCountry.text = "Country".localized()
let langs = Localize.availableLanguages()
print(langs[2])
@IBAction func IndexChanged(sender: UISegmentedControl)
{
var language: String = ""
switch self.LangChoser.selectedSegmentIndex
{
case 0: language = "de"
NSNotificationCenter.defaultCenter().addObserver(self, selector: "changeText", name: LCLLanguageChangeNotification, object: nil)
case 1: language = "fr"
NSNotificationCenter.defaultCenter().addObserver(self, selector: "changeText", name: LCLLanguageChangeNotification, object: nil)
default:
break;
}
func changeText (notification: NSNotification)
{
Localize.setCurrentLanguage(language)
}
}
Please if you can guide what I'm doing wrong here, thanks in advance.
Is there any way to reload a storyboard when you change the language? Currently when I change the language the Strings with .localized() work but the storyboard does not change at all.
Given this
"\nAnd %d more!".localizedFormat(aNumber)
genstrings.py doesn't generate any output for this string.
The reason behind this is because the regex matches localizedWithFormat, a non existing method.
When trying to install via cocoapods, if your project has a deployment target earlier than 8.0 (the one the pod is built with), you cannot install the pod.
According to the docs, Swift 2.0 is backwards compatible with iOS 7.0.
Appreciate the work!
I am gonna do some translation like "25yo" which the "25" passed as a variable outside.
Currently I found the python script will not sort it out if more than one times occurred in my code.
Seems it is a bug.
Thanks!
while building a swift project for MacOS i encountered the following problem:
`error: The dependency graph could not be satisfied. The package (https://github.com/marmelroy/Localize-Swift.git) with version tag in range (1.6.0..<1.6.1) is not found. Found tags ([0.0.1, 1.1.1, 1.1.2])`
My Package.swift:
import PackageDescription
let package = Package(
name: "test_swift",
dependencies: [
.Package(url: "https://github.com/marmelroy/Localize-Swift.git", "1.6.0")
]
)
The library looks great! I believe that the Localized()
method should be renamed to localized()
though as Swift conventions dictate that method names start with a lowercase letter. For instance, check out this style guide: https://github.com/raywenderlich/swift-style-guide
Use descriptive names with camel case for classes, methods, variables, etc. Class names should be capitalized, while method names and variables should start with a lower case letter.
Is the Persian support
Please add tvOS support.
I am using Swift 2 and have already import Localize to do i18n.
Everything works well, but i can not use genstrings.py to get the localized source string in swift files:
In swift file( test.swift):
label.text = "Name".localized()
after i run genstrings.py, nothing in the terminal, i suppose it could be like this:
/*
"Name" = "Name";
I am not familiar with RE and Python, after i tried many times, it still can not work as i hope.
can you help to fix it?
The platform of the target ShadowsocksX-NG
(OS X 10.10) is not compatible with Localize-Swift (1.1.2)
, which does not support osx
.
hi
i have multi view control and storyboard .
How do I change all together؟
Hi!
Will you add Swift 3 support in the near future?
If I try to run my app on iPhone 5 or iPhone 4s (using the simulator), xcode doesn't compiles and gives this error
Localize_Swift, file was built for x86_64 which is not the architecture being linked (i386)
I've imported the library using Carthage.
Anything I can do?
Would it be possible to change the the content direction when you set the language to a RTL language with setCurrentLanguage during runtime?
please change the typo mistake:
@IBAction func doResetLanguage(sender: AnyObject) {
Localize.resetCurrentLanguageToDefault() >>>>> to >>> resetCurrentLanaguageToDefault()
}
Hello,
No matter what I am doing, after settings the language to any different language than "en", I always get translations from Localizable.strings of my en.lproj.
I am using:
Localize.setCurrentLanguage("fr-FR")
and then after LCLLanguageChangeNotification notification, I call:
backButton.setTitle("Back".localized(), forState: .Normal)
The result is always the string "BACK".
Am I doing something wrong?
Thanks!
Hi,
while i'm trying to compile the Localize-Swift using carthage. i'm getting an Error.
The log file:
“Use Legacy Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choose a Swift version or use the Build Settings editor to configure the build setting directly.
Environment:
Xcode 8.0 Build version 8A218a
Swift 3.0
carthage version 0.18
Localize-Swift
Cartfile
github "marmelroy/Localize-Swift" "swift3.0"
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.