Firefox addon localization - 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.

Related

VSCode complains a Ruby UTF-8 file has invalid multibyte char (US-ASCII)

Using Rails 5.2 and Ruby 2.3 (ruby files by default are UTF-8).
If I check the file in the terminal:
file -I <filename>.rb
it shows UTF-8:
<filename>.rb: text/x-ruby; charset=utf-8
Yet in the file there is a string with a German umlaut character as you can see in the screenshot.
In pre v2.0 of Ruby you could use magic comments to tell Ruby the files encoding, but obviously this file is already UTF-8.
What I am trying to figure out is 2 things:
How did a UTF-8 file get this US-ASCII character inside it?
How can I fix it (so VS-Code is not showing it as incorrect)? I wonder if perhaps something to do with an extension or setting in VS-Code?.
In answer to (1) I am guessing it was perhaps copy and pasted from a file that was encoded US-ASCII (like Word)?
However if I delete the character and type it again on my Mac using OPT + u + u then VS Code still complains. Hence question 2.
With regard to (2) I checked this:
echo LC_TYPE
and it was null.
So I added export LC_TYPE=$LANG to my ~/.bash-profile and restarted VSCode, but that did not solve it (and in the VSCode integrated terminal LC_TYPE is still null). Ref
EDIT
There is no need to answer question 1, because if I delete the character and retype it, the same error shows up. So I now know it doesn't really matter how it got into the file, just need to know what is producing the warning.
I think the issue is in the linter.
"ruby.lint": {
"reek": true,
"rubocop": true,
"ruby": {
"unicode": true,
},
"fasterer": true,
"debride": false,
"ruby-lint": false
},
in settings.json unicode is not turned on by default for ruby.lint so you need to do that manually.

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.

iconv C API: charset conversion from/to local encoding

I am using the iconv C API and I want iconv to detect the local encoding of the computer. Is that possible? Apparently it is because when I look in the source code, I find in the file iconv_open1.h that if the fromcode or tocode variables are empty strings ("") then the local encoding is used using the locale_charset() function call.
Someone also told me that in order to convert the locale encoding to unicode, all I needed was to use iconv_open ("UTF-8", "")
Unfortunately, I find no mention of this in the documentation.
And when I convert some iso-8859-1 text to the locale encoding (which is utf-8 on my machine), then during conversion I get errno=EILSEQ (illegal sequence). I checked and iconv_open returned no error.
If instead of the empty string in iconv_open I specify "utf-8", then I get no error. Obviously iconv failed to detect my current charset.
edit: I checked with a simple C program that puts(nl_langinfo(CODESET)) and I get ANSI_X3.4-1968 (which is ASCII). Apparently, I got a problem with charset detection.
edit: this should be related to Why is nl_langinfo(CODESET) different from locale charmap?
additional information: my program is written in Ada, and I bind at link-time to C functions. Apparently, the locale setting is not initialized the same way in the Ada runtime and C runtime.
I'll take the same answer as in Why is nl_langinfo(CODESET) different from locale charmap?
You need to first call
setlocale(LC_ALL, "");

BlackBerry - language support for Chinese

I have localised my app by adding the correct resource files for various European languages / dialects.
I have the required folder in my project: ./res/com/demo/localization
It contains the required files e.g. Demo.rrh, Demo.rrc, Demo_de.rrc etc.
I want to add support for 2 Chinese dialects, and I have the translations in an Excel file. On iPhone, they are referred to by the codes zh_TW & zh_CM. Following the pattern with German, I created 2 extra files called Demo_zh_TW.rrc & Demo_zh_CN.rrc.
I opened file Demo_zh_CN.rrc using Eclipse's text editor, and pasted in line of the Chinese translation using the normal resource file format:
START_LOCATION#0="开始位置";
When I tried to save the file, I got Eclipse's error about the Cp1252 character encoding:
Save could not be completed.
Reason:
Some characters cannot be mapped using "Cp1252" character encoding.
Either change the encoding or remove the characters which are not
supported by the "Cp1252" character encoding.
It seems the Eclipse editor will accept the Chinese characters, but the resource tool expects that these characters must be saved in the resource file as Java Unicode /u encoding.
How do I add language support for these 2 regions without manually copy n pasting in each string?
Is there maybe a tool that I can use to Java Unicode /u encode the strings from Excel so they can be saved in Code page 1252 Latin chars only?
I'm not aware of any readily available tools for working with BlackBerry's peculiar localization style.
Here's a snippet of Java-SE code I use to convert the UTF-8 strings I get for use with BlackBerry:
private static String unicodeEscape(String value, CharsetEncoder encoder) {
StringBuilder sb = new StringBuilder();
for(char c : value.toCharArray()) {
if(encoder.canEncode(c)) {
sb.append(c);
} else {
sb.append("\\u");
sb.append(hex4(c));
}
}
return sb.toString();
}
private static String hex4(char c) {
String ret = Integer.toHexString(c);
while(ret.length() < 4) {
ret = "0" + ret;
}
return ret;
}
Call unicodeEscape with the 8859-1 encoder with Charset.forName("ISO-8859-1").newEncoder()
I suggest you look at Blackberry Hindi and Gujarati text display
You need to use the resource editor to make these files with the right encoding. Eclipse will escape the characters automatically.
This is a problem with the encoding of your resource file. 1252 Code Page contains Latin characters only.
I have never worked with Eclipse, but there should be somewhere you specify the encoding of the file, you should set your default encoding for files to UTF-8 if possible. This will handle your chinese characters.
You could also use a good editor like Notepad++ or EMEditor to set the encoding of your file.
See here for how you can configure Eclipse to use UTF-8 by default.

Character Encoding issue in Rails v3/Ruby 1.9.2

I get this error sometimes "invalid byte sequence in UTF-8" when I read contents from a file. Note - this only happens when there are some special characters in the string. I have tried opening the file without "r:UTF-8", but still get the same error.
open(file, "r:UTF-8").each_line { |line| puts line.strip(",") } # line.strip generates the error
Contents of the file:
# encoding: UTF-8
290919,"SE","26","Sk‰l","",59.4500,17.9500,, # this errors out
290956,"CZ","45","HornÌ Bradlo","",49.8000,15.7500,, # this errors out
290958,"NO","02","Svaland","",58.4000,8.0500,, # this works
This is the CSV file I got from outside and I am trying to import it into my DB, it did not come with "# encoding: UTF-8" at the top, but I added this since I read somewhere it will fix this problem, but it did not. :(
Environment:
Rails v3.0.3
ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-darwin10.5.0]
Ruby has a notion of an external encoding and internal encoding for each file. This allows you to work with a file in UTF-8 in your source, even when the file is stored in a more esoteric format. If your default external encoding is UTF-8 (which it is if you're on Mac OS X), all of your file I/O is going to be in UTF-8 as well. You can check this using File.open('file').external_encoding. What you're doing when you opening your file and passing "r:UTF-8" is forcing the same external encoding that Ruby is using by default.
Chances are, your source document isn't in UTF-8 and those non-ascii characters aren't mapping cleanly to UTF-8 (if they were, you would either get the correct characters and no error, and if they mapped by incorrectly, you would get incorrect characters and no error). What you should do is try to determine the encoding of the source document, then have Ruby transcode the document on read, like so:
File.open(file, "r:windows-1251:utf-8").each_line { |line| puts line.strip(",") }
If you need help determining the encoding of the source, give this Python library a whirl. It's based on the automatic charset detection fallback that was in Seamonkey/Mozilla (and is possibly still in Firefox).
If you want to change your file encoding, you can use gem 'charlock holmes'
https://github.com/brianmario/charlock_holmes
$require 'charlock_holmes/string'
content = File.read('test2.txt')
if !content.is_utf8?
detection = CharlockHolmes::EncodingDetector.detect(content)
utf8_encoded_content = CharlockHolmes::Converter.convert content, detection[:encoding], 'UTF-8'
end
Then you can save your new content in a temp file and overwrite your original file.
Hope this help.

Resources