I am using pootle for localization.
I imported source translations from Java properties files.
the property file looks like:
STR_TEXT1 = Hello
Than I imported other language files. I paid translators to translate those other languages.
Now I need to export those translations from pootle back to JAVA property files. Problem is, that it randomly exports it to UTF8 other time to to \uXXXX escape Encoding. There is no way how to setup the encoding for export files. Second problem is, that those export files are corrupted. It renders them like many rows without problem and some rows are cut, like this:
STR_TEXT1 = HELLSTR_TEXT2 = bye
Than I accidently deleted property files from /po/my_project directory. When I did this, exports stoped to work. But all translations are still wisible on the pootle web. So, i suppose those translations are saved in some other files, maybe mo files. Is there a way how to get those translations to java property files? how to force pootle to replace those original texts from original property files by fresh texts from pootle?
Pootle should export you files as Latin1 not UTF-8, it will escape non-Latin characters using \uXXXX syntax. Newer Pootle's allow you to export in UTF-8.
The best is to attach your source and translated files to a bug over at bugs.locamotion.org so that the Pootle developers can look at your source files.
The translations are kept in a database. Pootle makes use of you template file usually en.properties to create translated versions. I haven't tested what happens if you delete this template file.
Related
I need to use a library for my Java code, which comes in a handful (10 of them, to be exact) of .JAR files. No problem here.
The issue is trying to access these libraries' source code/files, so that my IDE can help me not f**k up anything.
See, the library actually did come with source files. One for each .JAR file.
The .JAR files are named in the format <pathToPackage>-<version>.jar, and the source files are named in the format <pathToPackage>.source-<version>.jar, with <pathToPackage> and <version> matching for every .JAR-source file duo.
However, for some unknown reason, only two (2) of them are successfully picked up by the IDE.
I tried with VScode (with the Java Language Support extension), and IntelliJ, both giving the same result.
All of the source files are "proper" source files. I extracted their content in a separate folder, and am using that to navigate the source code.
Here are the files, for reference (grouped by which ones work, and which ones don't):
https://drive.google.com/file/d/1MISJ7vML7WI9BDzPXf7yGtrTWc7MgRjI/view
I found abc.properties.tmpl file in a java project.Which is similar to abc.properties file.I am not aware why it is important to keep tmpl file in project.
What is the use of this file?
Since you haven't mentioned which IDE environment you are using and where (in which folder of the project) you found this, there could be lots of possibilities:
1) This might have been generated or kept by the IDE environment being used e.g. NetBeans, Eclipse. I cannot remember if it's specific to HTML or just any templates that require property settings.
2) This might have been generated by some old application which hasn't been cleaned up.
As I said, you have to update the question with more relevant information (perhaps some screenshots/snippets) for a better answer.
The file might have been copied twice and renamed. Or the guy created the tmpl file as a backup while working on abc.properties file.
Not known, "tmpl" would be "template." When there are multiple locales, en_US, nl_NL, nl, nl_BE they all are placed in their own properties file, having the same keys but different language texts.
So the tmpl file might be for a new language, or when a key/text is added, so all other properties must be updated by doing a text diff.
My guess is, that the tmpl file does not need to be distributed. Check the produced jar, the build, references to tmpl.
I know Java uses UTF-16 internally and expects .properties files to be in ISO-8859-1 by default.
I'm currently working on a project that was written in Eclipse, whose default encoding on our systems is cp-1252. I'm thinking utf-8 would be a much more sensible option, going forward.
However, given the scale of the project (it's split up into modules and uses libraries from all over the place), I can't just batch-convert all source code files in one go.
Will Java have a problem with some files in a project being in one encoding and some in another? (Clearly, having entire libraries written in encodings that are different from one another doesn't seem to be a problem - probably because they are all UTF-16 once compiled, anyway.)
Would Eclipse be able to handle that (i.e. different encodings per file) correctly?
Yes you can.
You can choose the default encoding to use for the whole Eclipse project:
right click on a project
resource part
Text file encoding zone, check Other and choose UTF-8 (or what you want) in the combo
You can also change the encoding for a particular file:
right click on the file
resource part
Text file encoding zone, check Other and choose UTF-8 (or what you want) in the combo
Preferences are store in the hidden folder .settings in your project. File encoding preferences are store in the .settings/org.eclipse.core.resources.prefs.
Thoses preferences can be commited using your favorite source control and shared with other developpers.
I am facing an encoding issue in my web application.
I am using properties file (resource bundle) to store language text.
If I check encoding of my properties file using notepad, it's UTF-8 and I see proper arabic character when I open it in notepad.
LOGIN=دخول
When I build my application using JDeveloper, in my properties file under classes folder, arabic characters are converted like this:
LOGIN=\u062f\u062e\u0648\u0644
Also encoding of this file is shown as ANSI in notepad.
Surprisingly, in browser, characters appeared perfectly fine (دخول).
Now when I build my application using ant, I've a copy task which is copying this properties file from src folder to classes folder.
After running build script, if I see encoding of properties file under classes folder, it still is UTF-8 and characters are in arabic only.
However in browser, characters doesn't appear properly.
As far as I know UTF-8 encoding is supposed to cater for all languages but in my case something is wrong somewhere.
I tried following also in copy task:
encoding="UTF-8" outputencoding="UTF-8"
However still no luck.
Anyone know where I am wrong?
Thanks.
Well, the comment and link provided by Edwin did help.
I moved my translations to XML bundles (also called as XLF or XLIFF bundle in ADF) and now everything is working fine.
Thanks.
right click the properties file > prefrences > Environment > Encoding >utf8
If I create a text file on an operating system that uses the Latin encoding code page ISO/IEC 8859-1. Now if I package the text file as a .war file using the Java jar tool, will it be packaged using the same character encoding as it was on the source Operating System? Or, will it be packaged using some standard encoding such as UTF-8?
The character set encoding for JAR/WAR/EAR is UTF-8. Note however, that this only applies to the entry names, not the file contents, e.g. class file data.
WAR file is basically a ZIP archive with .war extension and it has nothing to do with encodings.
Seems like jar takes the bytes from the text file and stores exactly those bytes in the jar/war file without storing any encoding information. This is gleaned from comments on the question as well as the other answers. The answers do not state this clearly, so I am answering my own question. Please correct if I am wrong.