////
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at
  http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
////
:description: Hop is already being used in many countries across the world where different languages are spoken. As such "internationalisation" represents the support for multiple languages in our software. Since it is such a long word it is typically abbreviated to i18n.
[[Internationalisation-Internationalisation]]
= Hop internationalisation

== Using Weblate

=== Use Weblate as a Translation Tool

Weblate official website: https://weblate.org

Weblate documentation: https://docs.weblate.org

Weblate source code: https://github.com/WeblateOrg/weblate

Apache Hop project translation address: https://translate.project-hop.org

You can go to the Apache Hop project translation page and participate in the translation work of the project. Thank you for your participation.


== Translating changes in the source code

The message bundles that contains the translations for the various parts of Hop are part of the source code.
If you want to start any i18n efforts we recommend that you set up your development environment first as described here:

xref:setup-dev-environment.adoc[Setting up your development environment]

== How is it configured?

In the Hop configuration file ```hop-config.json``` there is an entry called ```LocaleDefault``` which points to the locale string that you want to use.
Such a locale string is always in the format: language code, underscore and country.
For example, the default is en_US for English in the US.

You can change the locale you want to use in the configuration file or in the Hop GUI under the Tools / options menu.

== Translating strings

=== In Java code

Suppose we're working on a class in file ```src/main/java/org/apache/hop/p1/Foo.java``` What we want to do is have an easy way to get our hands on a translated String.
The easiest way to do this is with the standard BaseMessages class.
For example, you can see the following pop up all over the place in the Apache Hop source code:

[source]
----
org.apache.hop.i18n.BaseMessages.getString(PKG, "Foo.MyMessage");
----

If references a PKG variable typically defined at the top of the class like this:

[source]
----
private static final Class<?> PKG = Foo.class;
----

By doing this we know the location of the message bundles that will be used for translations.
In this case the message bundles will be looked for in

[source]
----
src/main/resources/org/apache/hop/p1/messages/
----

For the default locale ```en_US``` it will point to a file called messages_en_US.properties in that folder:

[source]
----
src/main/resources/org/apache/hop/p1/messages/messages_en_US.properties
----

In that file we can place an entry:

[source]
----
Foo.MyMessage = My own personal message
----

=== In annotations

Many plugin and GUI annotations support i18n as well.
Unfortunately it is not possible to use the method explained above to resolve keys into strings.
Because of this we use the following format:

[source]
----
i18n:package:key
----

For example, the main File menu in the Hop GUI is defined with an annotation:

[source]
----
@GuiMenuElement(
      root = ID_MAIN_MENU,
      id = ID_MAIN_MENU_FILE,
      label = "i18n::HopGui.Menu.File",
      parentId = ID_MAIN_MENU)
----

With the ```i18n:``` prefix the Hop GUI registry knows that it can translate this using the given package and key.
If there is no package defined it simply means: use the package from the current class.
In our example it is ```org.apache.hop.ui.hopgui``` which means that we can find the message bundles for this class in ```ui/src/main/resources/org/apache/hop/ui/hopgui/messages/``` and for locale ```en_US``` in :

[source]
----
ui/src/main/resources/org/apache/hop/ui/hopgui/messages/messages_en_US.properties
----

In there we can find the English translation:

[source]
-----
...
HopGui.Menu.File=&File
....
-----

