I am looking for a project to automatically translate my java properties files!
I just tried copy/paste the entirety of a properties file in translate.google.com and it the translator respected the file format keeping the keys intact while translating only the values!!!! Amazing job Google.
Depending on the number of files you have to translate it might be a long process to do it one by one (there is also 5000 character limit) but in the case of few files, it is a very viable solution to automation.
I have found a recent and maintained project for google translate of java properties files:
translate
Unfortunately I need an api key and for that a business account, which I do not have...
I still cannot translate my java properties files :-(
I cannot recommend to auto-translate. But I can recommend to maintain your translations in better way than properties files. This plugin will automatically compile your translations into properties files: https://github.com/hoereth/i18n-maven-plugin/blob/master/doc/README_JAVA.md
Feel free to ask me if you have troubles using it.
Related
I have been coding for about a month and I have found ways to adapt around ever problem but one. The problem as you can probably see by the title is how to make a way to make game saves. I am currently creating a very simple game that has about 5 classes of my code and maybe 2 of Java Swing GUI.
I know how I would like to go about the saving process but I have no idea how to do it in my code. How I would like to go about doing this is by making the code print a Number or Integer to a file to represent a Level. For example if you completed level 1 the number in the file would be 1. I have tried some templates for this but none of them work.
I understand how to write to a file but my problem is reading it from a jar or even creating a file then reading it from a place on the computer. I need to know how to find a file URL for different computers because some use Docs and Settings and other Users. Please could someone help.
Since the jar is read only, it can only contain the 'default settings'. See this answer for the general strategy to deal with such a embedded-resource.
Speaking of which (embedded resources) see the info. page for more details on how to access them.
Here is an example of storing and reading a Properties file from the 'current directory'.
As mentioned by #MadProgrammer though, it is safest to put the settings file into a (sub-directory) of user.home, as seen in this answer.
But a properties file is just one option. You might also serialize an object, or write the file in a custom format that your app. knows how to read, for the first two off the top of my head.
Besides 'serialize (in some form) in a File', there is also the Preferences API, or for desktop applications launched using Java Web Start, the PersistenceService. Here is a demo. of the service.
I need to know how to find a file url for different computers because
some use Docs and Settings and other Users
The System property user.home points to the user's home directory
File userHome = new File(System.getProperty("user.home"));
This question is not specifically related Git. I want to create a properties/configuration file in Java with groups (similar to .gitconfig). For example, I want to group the properties as follows
[group1]
prop1=value1
prop2=value2
[group2]
prop1=value1
prop3=value3
Instead of
group1.prop1=value1
group1.prop2=value2
group2.prop1=value1
group2.prop3=value3
I researched internet thoroughly but didn't find anything related to grouping of properties. May be I am not searching with right keywords. Excuse me if I may have missed something online.
Thanks
It is the same format used by the windows "ini" files.
There is a niche Java Library for that.
See: What is the easiest way to parse an INI file in Java?
I have a small java utility application which performs tasks on remote computers. This app will provide user with a dropdown/combobox where they can enter ip address or hostnames for the computers they wish to connect to. It would be nice if the users could have a history of items/hosts they had connected in the dropdown.
I thought that I can create a file inside the distributable jar and use it to maintain the history. But writing to a file inside the jar seems to be impossible? The alternate approaches would be to use text files, databases etc located outside the jar. But this is not quite I would like to do as my utility app is only one file and I would like it to be completely independent of any external files. Also its not nice to have a text file stick around your jar file or create a text file each time your app is run.
Considering this case what options can I use? Are there any apis that can help in storing or keeping history?
Why don't you store this info with an hidden file in the user home directory? Many application do the same thing.
You can get the user home directory in this way
String userhome = System.getProperty("user.home");
I'd recommend keeping some .dat file somewhere associated with the JAR. Could be in same directory, or in the user's home (as #dash1e recommends) to avoid any permissions issues. I think you'll find that's the simplest solution.
Another option would be to use a Java-based database solution which could be bundled into your JAR (see Apache Derby, et al). Note that this would create files somewhere, but you wouldn't have to worry about the file-level management, as you'd just be interacting with it as a database.
One final option, if you really insist on avoiding having to maintain your own file, would be to use the Java Preferences API which provides an OS-agnostic way of storing data on the system in some obfuscated location. This is arguably a bit of a misuse of the goal of this API, but would accomplish what you're asking for.
I stumbled upon the need to find out (inside Java code) which files are dynamically loaded by an SWF-file. Is there any possibility to get a list of paths of every object referenced inside?
I tried out some libraries without proper documentation and gave up. Although I ran out of Google Search Phrases... ;)
Maybe there is an external tool which can be accessed by Java via command line?
Ggreat thanks in advance
Maybe you can get to the information you need using the dump tool which is part of Apparat.
I use actionscript more than Java, so I also recommend having a look at AS3SWF which is a great library you could use to load and analyze the swf you need. Think of it as decompiling at runtime.
Either way, the SWF Format Specifications will come in handy.
I'm not sure there's something that does exactly what you want, but I imagine you could collect all the strings (DefineText tags), loop through them and run an URL RegEx against them.
I think even if you could analyze a SWF file, you can't be sure to get this information. I have Flex Project (finally a swf file) which dynamically loads some modules, but the names (URLs) of the available modules are requested from the server. So there is no chance to retrieve this information from the main swf file.
What we do in our company to let our software be translated by external translators is ... well .. how to put it...
cvs co someModule
ant translation.export (behind this target there is a self-made ant task, exporting all resource bundles together as one big tab-seperated text file, columns: the different languages, each row all languages for one key)
Some VB tool does something with the file (you don't wanna know)
Translators work in Excel on their column
Someone collects and merges the translations
VB tool
ant translation.import
cvs commit
...
Best case: 2 weeks between 1. and 8., development goes on...
First question: How do you handle this?
My idea was to build a tool with a web-gui that allows translators to work directly on cvs module (checkout in background and commit on "save", maybe tagging in background). We started with implementation by trainees and got something like a proof of concept. Before we go on with development I'd like to know
Second question: Do you know of a comparable tool?
and/or
Third question: Would you use such a tool?
java also provides its own resource bundle editor.
You should use gettext and Poedit. Translations are kept in separate files.
We use Sisulizer to localize our applications (.NET), for what I see in the documentacion of the application, it also supports Java, maybe this can help you.
With Sisulizer you can generate a translation project that you send to translators and when they return you it translated you can import the translation directly into the project.