Skip to content

lutece-core - Internationalization - The i18n cannot be used when #127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/java/fr/paris/lutece/portal/service/i18n/I18nService.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@
*/
public final class I18nService
{
private static final String FORMAT_PACKAGE_PORTAL_RESOURCES_LOCATION = "fr.paris.lutece.portal.resources.{0}_messages";
private static final String FORMAT_PACKAGE_PLUGIN_RESOURCES_LOCATION = "fr.paris.lutece.plugins.{0}.resources.{0}_messages";
private static final String FORMAT_PACKAGE_MODULE_RESOURCES_LOCATION = "fr.paris.lutece.plugins.{0}.modules.{1}.resources.{1}_messages";
public static final String FORMAT_PACKAGE_PORTAL_RESOURCES_LOCATION = "lutece.format.package.portal.resources.location";
private static final String FORMAT_PACKAGE_PLUGIN_RESOURCES_LOCATION = "lutece.format.package.plugin.resources.location";
private static final String FORMAT_PACKAGE_MODULE_RESOURCES_LOCATION = "lutece.format.package.module.resources.location";
private static final Pattern PATTERN_LOCALIZED_KEY = Pattern.compile( "#i18n\\{(.*?)\\}" );
private static final String PROPERTY_AVAILABLES_LOCALES = "lutece.i18n.availableLocales";
private static final Locale LOCALE_DEFAULT = new Locale( "", "", "" );
Expand Down Expand Up @@ -199,7 +199,7 @@ public static String getLocalizedString( String strKey, Locale theLocale )
String strBundleKey = strKey.substring( 0, nPos );
String strStringKey = strKey.substring( nPos + 1 );

String strBundle = FORMAT_PACKAGE_PORTAL_RESOURCES_LOCATION;
String strBundle = AppPropertiesService.getProperty( FORMAT_PACKAGE_PORTAL_RESOURCES_LOCATION );

if ( !strBundleKey.equals( "portal" ) )
{
Expand Down Expand Up @@ -246,7 +246,7 @@ public static String getLocalizedString( String strKey, Locale theLocale )
}
catch( Exception e )
{
String strErrorMessage = "Error localizing key : '" + strKey + "' - " + e.getMessage( );
String strErrorMessage = "Error localizing key : '" + strKey + "' - " + e.getMessage( );

if ( e.getCause( ) != null )
{
Expand Down Expand Up @@ -275,7 +275,7 @@ private static String getPluginBundleName( String strBundleKey )
Object [ ] params = {
strBundleKey
};
MessageFormat format = new MessageFormat( FORMAT_PACKAGE_PLUGIN_RESOURCES_LOCATION );
MessageFormat format = new MessageFormat( AppPropertiesService.getProperty( FORMAT_PACKAGE_PLUGIN_RESOURCES_LOCATION ) );
strBundle = format.format( params );
_pluginBundleNames.put( strBundleKey, strBundle );
}
Expand All @@ -302,7 +302,7 @@ private static String getModuleBundleName( String strPlugin, String strModule )
Object [ ] params = {
strPlugin, strModule
};
MessageFormat format = new MessageFormat( FORMAT_PACKAGE_MODULE_RESOURCES_LOCATION );
MessageFormat format = new MessageFormat( AppPropertiesService.getProperty( FORMAT_PACKAGE_MODULE_RESOURCES_LOCATION ) );
strBundle = format.format( params );
_moduleBundleNames.put( key, strBundle );
}
Expand All @@ -326,7 +326,7 @@ private static String getPortalBundleName( String strElement )
Object [ ] params = {
strElement
};
MessageFormat format = new MessageFormat( FORMAT_PACKAGE_PORTAL_RESOURCES_LOCATION );
MessageFormat format = new MessageFormat( AppPropertiesService.getProperty( FORMAT_PACKAGE_PORTAL_RESOURCES_LOCATION ) );
strBundle = format.format( params );
_portalBundleNames.put( strElement, strBundle );
}
Expand Down
5 changes: 5 additions & 0 deletions webapp/WEB-INF/conf/lutece.properties
Original file line number Diff line number Diff line change
Expand Up @@ -290,3 +290,8 @@ core.include.themes.enabled=true
#### XPages activations
core.xpage.search.enabled=true
core.xpage.map.enabled=true
################################################################################
#### Package format
lutece.format.package.portal.resources.location=fr.paris.lutece.portal.resources.{0}_messages
lutece.format.package.plugin.resources.location=fr.paris.lutece.plugins.{0}.resources.{0}_messages
lutece.format.package.module.resources.location=fr.paris.lutece.plugins.{0}.modules.{1}.resources.{1}_messages