dellermann / i18n-asset-pipeline

An asset-pipeline plugin for client-side i18n.
Apache License 2.0
3 stars 8 forks source link

Translations from plugins not found #4

Open alferink opened 9 years ago

alferink commented 9 years ago

I have one plugin which contains a file grails-app/assets/javascripts/plugin-messages.i18n. The file plugin-messages.i18n contains severals messages keys. The translation is defined in a messages_de.properties.

Then I have a app with a file grails-app/assets/javascripts/messages_de.i18n with the content "@import plugin-messages.i18n"

A request to the url http://localhost:8080/app/assets/messages_de.js?compile=false return:

(function (win) {
    var messages = {
        "kendoui.column.sortAscending": "kendoui.column.sortAscending",
        "kendoui.column.sortDescending": "kendoui.column.sortDescending",
        "kendoui.column.filter": "kendoui.column.filter",
        "kendoui.column.columns": "kendoui.column.columns"
    }

    win.$L = function (code) {
        return messages[code];
    }
}(this));

So the messages of the plugin is not translated. It only works if the messages are defined in the app.

The reason seems to be in I18nProcessor.groovy. In the process Method only the resource file from the current grails project is used. It would be probably necessary to iterate over all plugins.

aarifIg commented 9 years ago

produced at my end..

aarifIg commented 9 years ago

when this bug will fix. please do it asap

dellermann commented 9 years ago

Do you have the message keys and their translations in grails-app/i18n/message*.properties? This asset pipeline plugin expects theses files where it takes the translations from.

aarifIg commented 9 years ago

My project structure is modularized, i have plugin in one module and messages* .properties in other module.

dellermann commented 9 years ago

I'm sorry, but I have no knowledge how to obtain message files from other plugins. Thus, I cannot support this feature for now.

aarifIg commented 9 years ago

I found the solution.... Change messages*.properties location from I18nProcessor.groovy.

in process method- StringBuilder buf = new StringBuilder('[messages.properties location]')

works for me...

dellermann commented 9 years ago

Would you please submit a piece of code?

aarifIg commented 9 years ago

This is the file(I18nProcessor.groovy)-

String process(String inputText, AssetFile assetFile) { AssetFile f = (AssetFile) assetFile Matcher m = f.name =~ /.(\w+).i18n$/ StringBuilder buf = new StringBuilder("modules/[module-name]/grails-app/i18n/messages") if (m) buf << '' << m.group(1) Properties props = loadMessages(buf.toString())

aarifIg commented 9 years ago

Hi,

how can i use java script message with arguments.