Issue with genstrings for Swift file
localization not working swift
how to change localization internally in your ios application swift
swift localization best practices
nslocalizedstring not working swift 4
xcode localize storyboard strings
xcode localization catalog
genstrings works well to extract localizable content from .m file as,
find . -name \*.m | xargs genstrings -o en.lproj
But, not working for .swift file as,
find . -name \*.swift | xargs genstrings -o en.lproj
genstrings tool works fine with swift as far as I am concerned. Here is my test:
// MyClass.swift let message = NSLocalizedString("This is the test message.", comment: "Test")
then, in the folder with the class
# generate strings for all swift files (even in nested directories) $ find . -name \*.swift | xargs genstrings -o . # See results $ cat Localizable.strings /* Test */ "This is the test message." = "This is the test message."; $
Problems with genstrings in Swift …, -name "*.swift" -print0 | xargs -0 genstrings -o en.lproj. to generate my strings file. Searching the usual places (like stackoverflow) indicates that this problem has existed for a Instead, the workflow is to export (and later re-import) LIFF files. The exporter will only export for language which are NOT in the development language. In the past, you could use genstrings to create them, but now genstrings doesn't fully support swift, I don't see an easy way to keep the development language strings updated from the source of truth in the code. I asked the question on stackoverflow here:
We wrote a command line tool that works for Swift files and merges the result of apples
It allows for
How to localize your iOS app, swift file is. Now run this command: genstrings -o en.lproj *.swift – that means “ read all Swift files for localized strings, then write� 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
genstrings works as intended, however Apple's
xargs approach to generate strings from all your project's files is flawed and does not properly parse paths containing spaces.
That might be the reason why it's not working for you.
Try using the following:
find . -name \*.swift | tr '\n' '\0' | xargs -0 genstrings -o .
kayak/SwiftGenStrings: genstrings replacement for Swift , The upstream issue is tracked here. Usage. SwiftGenStrings files SwiftGenStrings [-s <routine>] [-o <outputDir>] files SwiftGenStrings [-h|--help]� genstrings with Swift hori,masaki Dec 25 LocalizedStrings struct in LocalizedStrings.swift. this file is actual Localize settings. [Issue #1] #codenewbie #
There's an alternative tool called SwiftGenStrings
NSLocalizedString("hello", value: "world", comment: "Hi!")
$ SwiftGenStrings Hello.swift /* Hi! */ "hello" = "world";
$ genstrings Hello.swift Bad entry in file Hello.swift (line = 1): Argument is not a literal string.
Disclaimer: I worked on SwiftGenStrings.
A different way to deal with Localized strings in Swift, Apple has never provided a good way to deal with this issue in a clean our custom genstrings tool to generate Localizable.strings files which� SwiftGenStrings. SwiftGenStrings is a command line application that can be used as a drop-in replacement for the standard genstrings command for Swift sources. The latter only supports the short form of the NSLocalizedString function but breaks as soon as you use any parameters other than key and comment as in
There is a similar question here: How to use genstrings across multiple directories?
find ./ -name "*.m" -print0 | xargs -0 genstrings -o en.lproj
Things that you should know while localizing your iOS app, This is an Apple's tool, that scans your .swift and .m files and extracts Xcodebuild will actually do genstrings' job, but the problem is� For more information about using the genstrings tool, see the genstrings man page. Creating Strings Files Manually. Although the genstrings tool is the most convenient way to create strings files, you can also create them manually. To create a strings file manually, create a new file in TextEdit (or your preferred text-editing application) and
genstrings Not Working? : swift, I have been trying to use genstrings to make a .strings file. instructions from this site: https://github.com/nodejs/node-gyp/issues/569 saying to change the path. Hey, Thanks for this great tool and support for the fonts! I added a strings template to support a particular workflow regarding strings. genstrings tool extracts all strings in NSLocalizedString calls into a Localizable.strings file.
rdar://24770264: genstrings fails for Swift calls to NSLocalizedString , genstrings fails for Swift calls to NSLocalizedString with more than a key and a Summary: The genstrings utility searches source files for uses of seems to indicate this has been a problem since at least Xcode 7.0. I tested� Resolved Issues. Code completion works for Swift package targets regardless if the name of the target declared in the Package.swift manifest file differs in casing with the directory name for that target. (49648458) Adding a new file in a C-family target of a Swift package doesn’t create the file with the .swift extension. (31395814)
The mini-blog — Alternatives to genstrings for swift projects, Alternatives to genstrings for swift projects My usual genstrings script works well for Objective-C Few experimenting resulted in two scripts for export and import of xliff files. My tool uses dynamicly built ffmpeg and ffprobe, problem solved :). Localize-Swift. Localize-Swift is a simple framework that improves i18n and localization in Swift iOS apps - providing cleaner syntax and in-app language switching. Features. Keep the Localizable.strings file your app already uses. Allow your users to change the app's language without changing their device language.
- I see, genstrings tracks NSLocalizedString, but I have used string extension like localizedString(). So my string becomes "This is the test message.".localizedString() and that's why it is not being tracked
- Well, you know what to do. Your problem can be solved with one smart global text replace operation. Start by ticking the checkmark above ;-).
genstringsdoes not work for any long-form (arguably best practice) usage:
NSLocalizedString("checkout-okbtn", value: "Ok", comment: "in cart checkout, the button that pays")radar issue
- Wait, I just realize why. I'm running a genstrings command where I'm only looking for *.m files. Let me see if I can alter that to find both *.m and *.swift in one go...
- Yes, working fine for both Objective-C and Swift in my mixed project now I changed the command to the following:
cd ~/Workspace/ios-ecentral-app/ECentral/;find ./ -type f \( -iname \*.m -o -iname \*.swift \) | xargs genstrings -o ECentral/localization/en.lproj/'
- philipp, I have a project that is a mix of Objective-C and Swift. I have found that the
genstringstool only finds the message from the Objective-C source code. This genstrings_swift tool, can it be run on a mixed-code project like mine and find all the messages in one go, or do I need to follow a sequence of steps?
- This is the genstrings command I am using now, by the way:
cd ~/Workspace/ios-ecentral-app/ECentral/;find . -name \*.m | xargs genstrings -o ECentral/localization/en.lproj/
- Oh wait... doh! I should edit that command to include *.swift...!
- Okay, fixed by changing my alias to the following:
alias genstringsECentral='cd ~/Workspace/ios-ecentral-app/ECentral/;find ./ -type f \( -iname \*.m -o -iname \*.swift \) | xargs genstrings -o ECentral/localization/en.lproj/'-- works like a charm now.
- This solved my problem with some declarations that included newline. Thank you!
find . -name \*.swift -print0 | xargs -0 genstrings -o ., no need for replacing anything with