Reply To: Adding language code in the page adress – Multi-language url rewiting

Splash Forums PrettyFaces Users Adding language code in the page adress – Multi-language url rewiting Reply To: Adding language code in the page adress – Multi-language url rewiting

#27450

vector_ever
Participant

Your solution not clear enough to me, also it describes another case.

Again I am not sure if I did it correctly When I run my project I still get : http://localhost:8080/Wirote/index.xhtml

My properties (lang.properties) files in the following location:

src/main/resources/I18n/lang.properties

But in the example they have another location:

src/main/java/org/example/Paths_en.properties ( it is in Java instead of resources)

I mean instead of resource folder you have it in java package!

The most importan property in the properties file is “language” which is resolve to language code

    src/main/resources/I18n/lang.properties .... language = en
    src/main/resources/I18n/lang_en.properties .... language = en
    src/main/resources/I18n/lang_de.properties .... language = de
    src/main/resources/I18n/lang_ar.properties .... language = ar

according to this I change the code to be:

public class LocalizedConfig extends HttpConfigurationProvider{
   @Override
   public Configuration getConfiguration(final ServletContext context)
   {
      return ConfigurationBuilder.begin()
               .addRule(Join.path("/{language}/{path}").to("/{path}.xhtml"))
               .where("path").transposedBy(LocaleTransposition.bundle("I18n.lang", "language"));
   }
    @Override
    public int priority() {
        throw new UnsupportedOperationException("Not supported yet."); 
    }}

I know something is wrong but I don’t know what it is.