Change text encoding to No Explicit in localizable file - ios

Currently my text encoding of the Localizable.strings file is set to UTF-8. All my other localizable files are set to no explicit.
I want to change UTF-8 to No explicit, how is it possible ?
If you want to know, it's cause with xCode 10 this error appears
could not decode input file using specified encoding: Unicode (UTF-8), and the file contents appear to be encoded in Unicode (UTF-16)

You could try manually editing the project.pbxproj file to remove the fileEncoding = x for your Localizable.strings file?

To reset the Text-Encoding type. Select your language.string file:
Then select Text Encoding from right hand panel:
Update:
If you accidentally selected the Text-Encoding, then you have to reset it from project.pbxproj. To do this follow below steps:
Open package content of your Project.xcodeproj
Open project.pbxproj and search for your file-name and remove the fileEncoding = <encoding>; (for example: fileEncoding = 4;), and save the file.

Related

Xcode archive error: detected encoding of input file as Unicode (UTF-8)

The following error occurred when performing iOS app archive:
/Users/enix/source/apple/xxx-iOS/xxxxxx/fr.lproj/Localizable.strings:1:1: note: detected encoding of input file as Unicode (UTF-8) (in target 'xxxx' from project 'xxx')
/Users/enix/source/apple/xxx-iOS/xxxxxx/fr.lproj/Localizable.strings:1:1: error: validation failed: Couldn't parse property list because the input data was in an invalid format (in target 'xxxx' from project 'xxxxxxx')
I had tried with iconv to convert the localized string to UTF-8 and UTF-16, but still not work.
So, my question is what file encoding format does XCode expect?
After asking this question in apple forum, I got the answer finnally:
This is controlled by the Text Settings pane within in the File inspector. > Select the .strings file on the left and choose View > Inspectors > File.
https://developer.apple.com/forums/thread/713382?page=1#725798022

Xcode 10, could not decode input file using specific encoding

I am working on an iOS app. It is working fine in Xcode 9.4.1, but when I build it in Xcode 10 it gives me following error:
I tried the solution given in the following post by changing the encoding, but it didn't work. I tried it by both Reinterpret and Convert
still the same error:
It's working fine on Xcode 9.4.1
Find your Localizable.strings in a Terminal and execute:
$ iconv -f UTF-16LE -t UTF-8 Localizable.strings > LocalizableNew.strings
Then check LocalizableNews.string
and if there is no errors just replace files
$ mv LocalizableNew.strings Localizable.strings
I have similar error once i open my project in Xcode 10.4 and open it agian in Xcode 10.1.
I solved it by selecting my all Localizable.strings file and change there text encoding to UTF-16(In my case error was related to UTF-16 you can change it to UTF-8)
So changing the text encoding to UTF-16 or UTF-8 will works.
It sounds like the file is corrupted, probably with parts of it encoded in UTF-8 and parts of it encoded in 8859-5. From its name, I would suspect this is a Cyrillic localization (perhaps Russian), and the file was probably edited using an editor that didn't correctly maintain encoding or use UTF-8 (the most common cause of that is editing on Windows).
You'll need to open the file, probably in an external editor that can handle random encodings like vim or Sublime Text, and fix any corruption. Exactly how to do that depends on the nature of the corruption.
You need to set correct Text Encoding in the File Inspector. The default is UTF-8.
If you want to fix the problem without UI, you need to look for the XCode project definition (generally YOURPROJECT.xcodeproj/project.pbxproj), then find the reference to the file causing an issue.
You should find something like this (from Adium, in this case)
D182F1B611DFF23700E33AE2 /* sk */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = sk; path = sk.lproj/schema.strings; sourceTree = "<group>"; };
fileEncoding = 10 is UTF-16; 4 is UTF-8, which is currently the default, so you can either set it to that value explicitely, or simply remove the fileEncoding bit altogether.
I got this error message when I forgot to put semicolons at the end of the line to separate the individual translations.

Weird hidden characters in exported XLIFF file

Whenever I try to 'Export For Internationalization', the exported file contains a weird hidden character, making it unparsable for XLIFF editors. The problem seemed to be in the original .string files, somehow the weird character was inserted in those files. I have since deleted the weird character but whenever I export it still sneaks into the xliff file. I tried cleaning and rebuilding the project, restarting Xcode... none of that seems to work.
Is Xcode somehow using a cached version of the 'bad' .strings file containing the bad character?
Using Xcode
If I try Editor > Export For Localization
I get:
/usr/bin/xmllint exited with status 1
Using Terminal
When I run it from Terminal like so:
xcodebuild -exportLocalizations -localizationPath
/Users/Kymer/Downloads/Wolf -project Wolf.xcodeproj -exportLanguage fr
I get the following errors:
parser error : attributes construct error
parser error : Couldn't find end of Start Tag trans-unit
parser error : PCDATA invalid Char value 19
parser error : PCDATA invalid Char value 19
parser error : Opening and ending tag mismatch
parser error : invalid character in attribute value
parser error : attributes construct error
parser error : Couldn't find end of Start Tag
parser error : PCDATA invalid Char value
/Uxcodebuild: error: /usr/bin/xmllint exited with status 1
In both cases the exported xliff file contains the weird hidden character upon inspection with Sublime Text:
If I manually remove the bad characters the file is perfectly readable by xliff-editors but that's not a good long-term solution of course.
I found the problem: when exporting to an XLIFF file Xcode doesn't look at your .string files, it is all generated from the project itself (i.e. it looks at all NSLocalizedString calls and your storyboards). Which makes sense. I found the weird hidden character in one of my code files. Removing it from the source file fixed the export issue.
Easiest XLIFF workflow
I'll also mention this for future reference: the easiest way to add a new language to your project is to first use the command line:
cd to the your project and run:
xcodebuild -exportLocalizations -localizationPath <path> -project <projectname>.xcodeproj -exportLanguage <language code>
That creates a new XLIFF file and will correctly set the target language in the file (source language will be your base language). A translator can now easily add all necessary translations. Afterwards you can import the translated XLIFF file back into Xcode (select target and Editor > Import localizations). Xcode will then generate all necessary .string files.
Updating existing language: If you add new UI elements and want to update an existing localization language, you can simply export an existing localization (select target and Editor > Export for localization). That XLIFF file will contain all previous translations together with the new strings. A translator simply has to fill in the 'blank' lines. There's no need to touch the .string files yourself, because managing that manually is a pain (especially with the crazy Storyboard ID's).

saving data with TextEdit

I want to use TextEdit to save data. what I have so far
tell application "TextEdit"
open /Users/UserName/Desktop/save.rtf
end tell
This gives me
"Expected “given”, “in”, “of”, expression, “with”, “without”, other parameter name, etc. but found unknown token."
and highlights the . in .rtf I tried removing the .rtf
but when I compile it it turns into
(open) / Users / username / desktop / (save)
This code gives "The variable Users is not defined."
also if possible can I have TextEdit run in the background without opening a window?
Put quotes around the path and use POSIX file to get a file object for the path:
tell application "TextEdit"
open POSIX file "/Users/UserName/Desktop/save.rtf"
end tell
You can modify the text of a document by changing the text property:
tell application "TextEdit"
set text of document 1 to text of document 1 & "aa"
end tell
It removes all styles in rich text documents. It also inserts the text as 12-point Helvetica in plain text documents, regardless of the default font.
Creating a new rtf file:
tell application "TextEdit"
make new document at beginning with properties {text:"aa"}
close document 1 saving in POSIX file "/tmp/a.rtf"
end tell
printf %s\\n aa | textutil -inputencoding UTF-8 -convert rtf -stdin -output a.rtf

Firefox addon localization

I have problem with localization my addon. I followed this tutorial on Using Localized Strings in Preferences but I can't compile my addon because I use polish characters ć and others.
I've made locale folder and put there pl-PL.properties file with this content:
my_tag_title = Co robić?
and I got error:
Following locale file is not a valid UTF-8 file: C:\path\pl-PL.properties
'utf8' codec can't decode byte 0xe6 in position 22: invalid continuation byte"
Is there way to put special characters directly inside package.json?
How to solve this problem?
Make sure that the locale file is saved in UTF-8 format.

Resources