Coder Social home page Coder Social logo

gwt-i18n-server's People

Contributors

akbertram avatar atoy40 avatar geoffreywiseman avatar lightoze avatar robert7k avatar velo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

gwt-i18n-server's Issues

License

Hi, what is the project license?

Found nothing on pom, readme.md and java sources headers....

GWT-specific i18n formats not supported

The GWT-specific i18n format is currently not supported yet (See http://www.gwtproject.org/doc/latest/DevGuideI18nMessages.html#GwtFormats)

Here is a simple example :

In the properties file :

hello = Hello, {startBold,<b>}{0}{endBold,</b>}

When rendering this message on the server side, an exception will be thrown :

java.lang.IllegalArgumentException: can't parse argument number: startBold
    at java.text.MessageFormat.makeFormat(MessageFormat.java:1420)
    at java.text.MessageFormat.applyPattern(MessageFormat.java:479)
    at java.text.MessageFormat.<init>(MessageFormat.java:381)
    at net.lightoze.gwt.i18n.server.MessagesProxy.invoke(MessagesProxy.java:107)

Also look for properties files in root package

Hi,
I've noticed that LocaleProxy.loadBundle(Class clazz, String locale) searches for properties files only in the package of the clazz and its super classes. GWT 2.7 (and I strongly believe that same applies to 2.6) also searches the root package.

You probably dont want to run this in loadBundle as it would process the same bundle for each super class, but it should get incorporated in the dereferencing process:

InputStream stream = getClassLoader().getResourceAsStream(clazz.getSimpleName() + (locale == null?"":"_" + locale) + ".properties")

GWT 2.6 Support

GWT 2.6. compile fails with this error:

[ERROR] Exception in thread "main" java.lang.VerifyError: class com.google.gwt.i18n.tools.ArgHandlerValueChooser$1 overrides final method getPurpose.()Ljava/lang/String;
[ERROR]     at java.lang.ClassLoader.defineClass1(Native Method)
[ERROR]     at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
[ERROR]     at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
[ERROR]     at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
[ERROR]     at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
[ERROR]     at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
[ERROR]     at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
[ERROR]     at java.security.AccessController.doPrivileged(Native Method)
[ERROR]     at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
[ERROR]     at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
[ERROR]     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
[ERROR]     at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
[ERROR]     at com.google.gwt.i18n.tools.I18NSync.<init>(I18NSync.java:342)
[ERROR]     at com.google.gwt.i18n.tools.I18NSync.main(I18NSync.java:235)

Getting same translation for different locale

Hello,

I am trying to use your library for server translation but I can't make it work properly.

I am calling this in onModuleLoad() method:

LocaleFactory.put(Constants.class, GWT.create(Constants.class));

then I put this in our web.xml:

    <filter>
        <filter-name>i18n</filter-name>
        <filter-class>net.lightoze.gwt.i18n.server.I18nFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>i18n</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <listener>
        <listener-class>net.lightoze.gwt.i18n.server.I18nInitializer</listener-class>
    </listener>

then on server side (RPC service):

Constants locale = LocaleFactory.get(Constants.class);
System.out.println("message: " + locale.trCo_claim_search_state_CANCELED() + ", lang: " + LocaleProxy.getLocale().getLanguage());

I got translated message but always in default locale even when lang is changing correctly by parameter in URL. What I am doing wrong?

Thanks for help.

GWT 2.5 Support

It'd be nice if gwt-i18n-server would support GWT 2.5, which introduces some new constants (e.g. NumberConstants has a new globalCurrencyPattern.

If you think it'll be a while before you can do this, lemme know and I'll consider sending you a pull request.

ClassNotFoundException: SafeHtml on server when message contains parameter

Thanks for your work.

When using version 0.23 on the server side, and calling a Message method that has a parameter (eg: "Value: {0}"), I get the following:

Caused by: java.lang.NoClassDefFoundError: com/google/gwt/safehtml/shared/SafeHtml
        at com.google.gwt.i18n.server.Type.<clinit>(Type.java:114)
        at com.google.gwt.i18n.server.impl.ReflectionMessage.mapClassToType(ReflectionMessage.java:192)
        at com.google.gwt.i18n.server.impl.ReflectionMessage.access$100(ReflectionMessage.java:44)
        at com.google.gwt.i18n.server.impl.ReflectionMessage$ReflectionParameter.<init>(ReflectionMessage.java:52)
        at com.google.gwt.i18n.server.impl.ReflectionMessage.getParameters(ReflectionMessage.java:126)
        at com.google.gwt.i18n.server.AbstractMessage.init(AbstractMessage.java:341)
        at com.google.gwt.i18n.server.impl.ReflectionMessage.<init>(ReflectionMessage.java:101)
        at net.lightoze.gwt.i18n.server.LocaleProxy.getKey(LocaleProxy.java:193)
        at net.lightoze.gwt.i18n.server.MessagesProxy.getDescriptor(MessagesProxy.java:120)
        at net.lightoze.gwt.i18n.server.MessagesProxy.invoke(MessagesProxy.java:64)
        at com.sun.proxy.$Proxy593.lastN(Unknown Source)
        at com.saucontds.dlog.portal.view.DriverLogReportPDF$UsedHoursTable.<init>(DriverLogReportPDF.java:91)
        at com.saucontds.dlog.portal.view.DriverLogReportPDF.buildPdfDocument(DriverLogReportPDF.java:434)
        at saucon.portal.common.view.AbstractItextPDFView.renderMergedOutputModel(AbstractItextPDFView.java:59)
        at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:264)
        at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1208)
        at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:992)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:939)
        ... 25 more
Caused by: java.lang.ClassNotFoundException: com.google.gwt.safehtml.shared.SafeHtml
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1718)
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1569)
        ... 43 more

I believe this is due to line 114 in com.google.gwt.i18n.server.Type:

public static final Type SAFEHTML = new Type(SafeHtml.class.getCanonicalName());

SafeHtml is not present in the gwt-i18n-server jar.

I resolved it by building gwt-i18n-server myself and adding

<include>com/google/gwt/safehtml/shared/SafeHtml.class</include>

to the pom.xml under the maven-shade-plugin section.

Dead lock wjem accessing messages

Hello, we are getting DEAD LOCK problem in concurrent access;

java.lang.Thread.State: RUNNABLE
at java.util.Hashtable.get(Hashtable.java:458)

  • locked <0x0000000700a34e40> (a java.util.Properties)
    at java.util.Properties.getProperty(Properties.java:951)
    at net.lightoze.gwt.i18n.server.MessagesProxy.invoke(MessagesProxy.java:128)
    at net.lightoze.gwt.i18n.server.MessagesWithLookupProxy.invoke(MessagesWithLookupProxy.java:33)
    at com.sun.proxy.$Proxy0._894782(Unknown Source)

    java.lang.Thread.State: BLOCKED (on object monitor)
    at java.util.Hashtable.get(Hashtable.java:458)

  • locked <0x0000000700a34e40> (a java.util.Properties)
    at java.util.Properties.getProperty(Properties.java:951)
    at net.lightoze.gwt.i18n.server.MessagesProxy.invoke(MessagesProxy.java:128)
    at net.lightoze.gwt.i18n.server.MessagesWithLookupProxy.invoke(MessagesWithLookupProxy.java:33)
    at com.sun.proxy.$Proxy0._894782(Unknown Source)

Client and Server Side Locale Match Problem

Hi,

I've been using this library to set locale for both client and server side. However, I've hit a bump.

LocaleProxy class holds the locale, specific per thread (i.e. as a ThreadLocal variable). However, when I make calls from client side to server side, each time a different (seemingly random) thread is associated on server side. Hence, the server side returns localized results to the same client session with arbitrary locales.

What am I doing wrong? Any help would be appreciated.
I am using GWT 1.7 with Tomcat 6.0. Thanks.

Formating lists throwing exception

Hi,

A simple list format is throwing this exception below. Let me know if this is a know issue or under development. Maybe I can help.

java.util.ArrayList cannot be cast to java.lang.Number
Caused by:
java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.lang.Number
at net.lightoze.gwt.i18n.server.MessagesProxy.invoke(MessagesProxy.java:70)

Code:

@DefaultMessage("Weekdays {0,list,text}.")
@AlternateMessage({ "=1", "Weekday {0,list,text}."})
String weekdays(@PluralCount List listWeekDaysNames);

On Server:
LocaleProxy.initialize();
LanguageMessages messages = LocaleFactory.get(LanguageMessages.class);
ThreadLocalLocaleProvider.pushLocale(new Locale(someLocale));

List listNames = new ArrayList(0);
listNomes.add("sunday");
listNomes.add("monday");

String transationTest = messages.weekdays(listNames); //EXCEPTION HERE

Thanks in advance,
[],
Rodrigo

Use of java.util.Locale in LocaleFactory

I see that LocaleFactory in version 0.16 has java.util.Locale as a parameter in the put() method. java.util.Locale is not implemented in the GWT JRE. So this class is no longer valid to use on the client. Is that intentional and this lib is now only functional on the server?

Thanks
Travis

Allow for alternate means of getting the locale

LocaleProxy uses ThreadLocal to store the locale's. We use Play Framework at my office which doesn't work well with ThreadLocal. I suspect many of the newer async web frameworks will also have trouble.

Perhaps LocalProxy can take an optional argument if a LocaleProvider interface and the system can use the LocaleProvider to get the local and the user of the api could provide the LocaleProvider.

UTF-8 encoded properties files

I encountered a problem for strings in properties files that contain non ISO 8859-1 characters. My properties files are encoded as UTF-8 since they are primarily used in GWT which reads them as such.

The problem is that gwt-i18n-server relies on java.util.ResourceBundle which assumes the files are in ISO 8859-1 and this produces character sequences like é for é and so on.

My workaround is to do

new String(constants.propertyKey().getBytes("ISO-8859-1"), "UTF-8")

instead of

constants.propertyKey()

, but this should be done by gwt-i18n-server itself I think.

Bundle files searching

Hello,
i'm testing your librarie, and i've detected a limitation :
properties files are only searched based on the name of the class you asked for. For example :

LocaleFactory.get(MyMessages.class) will only search for MyMessage_*.properties

But in client-side GWT, the deferred binding search into the whole Inheritance tree, for example, if you have :

interface AppMessages extends Messages {
}

interface MyWidgetMessages extends AppMessages {
String mykey();
}

and have a GWT.create(MyWidgetMessages.class), it'll search properties into :

  • package/MyWidgetMessages_locale.properties
  • package/AppMessages_locale.properties
    and even :
  • com/google/gwt/i18n/client/LocalizableResource_locale.properties

In my case, the last file is the only one i define for my whole app (i mean, one per locale for sure)

Do you planned to add this feature (i'll check on my side btw) ?
Anthony.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.