blob: 91d9fdf13ca0f36bc0328a507cbe57b3f7a0f02b [file] [log] [blame]
//
// 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.
//
= DevFaqMavenL10N
:jbake-type: wiki
:jbake-tags: wiki, devfaq, needsreview
:jbake-status: published
:keywords: Apache NetBeans wiki DevFaqMavenL10N
:description: Apache NetBeans wiki DevFaqMavenL10N
:toc: left
:toc-title:
:syntax: true
=== How can I create localization modules using Maven?
If you have localized versions of resources _in your own modules_, you can simply place them alongside the base version; for example, `src/main/resources/my/module/Bundle_de.properties` would provide a German translation of `src/main/resources/my/module/Bundle.properties`.
But to localize _other people's modules_, then as explained in link:http://bits.netbeans.org/dev/javadoc/org-openide-modules/org/openide/modules/doc-files/i18n-branding.html#placement[Physical Placement of Localized Resources] you will need to create `modules/locale/*_*.jar` JARs with the localized resources. (Simply bundling localized resources in your own module will not work, because these are usually searched for starting with the original module's `ClassLoader`, which cannot "see" your modules.)
The simplest way to do this is to use the existing [link:http://mojo.codehaus.org/nbm-maven-plugin/branding-mojo.html[http://mojo.codehaus.org/nbm-maven-plugin/branding-mojo.html] `nbm:branding` goal], which despite its name can handle localization as well as branding. (These are nearly interchangeable in the NB Platform.) image:Localedemo.zip[] demonstrates how to localize parts of the Options dialog to Czech. Take note of:
* `lokalizace/pom.xml` asks to use this goal when building the module. It overrides the "branding token" (otherwise inherited from the parent POM) with your locale identifier. (Specifying this custom execution is required in the 3.3 plugin; future versions may run the goal automatically during the package phase when there is anything to process, but you would still need to declare the locale in your plugin configuration.)
* `lokalizace/src/main/nbm-branding/` contains the actual localizations.
* Localizations must be grouped by module to be localized, under a folder path matching the path of the original module in its cluster.
* The locale suffix (`_cs` in this case) is inserted automatically by the build, so the source file should be named simply `Bundle.properties`.
* `application/pom.xml` specifies `--locale cs` so that you can quickly test the localization just by running the app.
* It also turns on `NbBundle` debugging mode when requested by a special profile. This can be helpful to pinpoint where a particular English string is coming from: every visible string will be annotated with a bundle number (cross reference with console output) and line number. You can also use the Search field in the branding editor (available from the context menu of `lokalizace`) to find all potentially localizable strings in the Platform matching some keyword; this editor also creates the right folder structure for you automatically when localizing new bundles.
The module bundling the localizations can now be included in your app, or distributed by any other means. When the specified locale is active, your localizations will be applied.
=== Apache Migration Information
The content in this page was kindly donated by Oracle Corp. to the
Apache Software Foundation.
This page was exported from link:http://wiki.netbeans.org/DevFaqMavenL10N[http://wiki.netbeans.org/DevFaqMavenL10N] ,
that was last modified by NetBeans user Jglick
on 2011-01-21T13:59:19Z.
*NOTE:* This document was automatically converted to the AsciiDoc format on 2018-02-07, and needs to be reviewed.