Skip to content

Instantly share code, notes, and snippets.

@sergiomichels
Created July 23, 2013 16:18
Show Gist options
  • Select an option

  • Save sergiomichels/6063757 to your computer and use it in GitHub Desktop.

Select an option

Save sergiomichels/6063757 to your computer and use it in GitHub Desktop.
Update for ExposedKeysMessageSource, returning all PropertiesHolder to be used in the i18n javascript messages
package com.wordpress.sergiosmind.i18n
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
import org.codehaus.groovy.grails.context.support.PluginAwareResourceBundleMessageSource
import org.codehaus.groovy.grails.plugins.BinaryGrailsPlugin;
import org.codehaus.groovy.grails.plugins.GrailsPlugin;
import org.springframework.context.support.ReloadableResourceBundleMessageSource.PropertiesHolder
class ExposedKeysMessageSource extends PluginAwareResourceBundleMessageSource {
public Set getAllKeys(Locale locale) {
PropertiesHolder pluginProps = getMergedPluginProperties(locale)
Set pluginSet = pluginProps.getProperties().keySet()
PropertiesHolder props = getMergedProperties(locale)
Set propsSet = props.getProperties().keySet()
Set returnSet = [] as Set
returnSet.addAll(propsSet)
returnSet.addAll(pluginSet)
return returnSet
}
public List<PropertiesHolder> getAllProperties(Locale locale) {
List<PropertiesHolder> holders = []
holders << getMergedProperties(locale)
holders << getMergedPluginProperties(locale)
holders
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment