ResourceLocale implements IResourceLocale { public static IResourceLocale fromExternal(String external) { if(external.indexOf('_') != -1){ List<String> localeInfo = Splitters.by('_').split(external); return new ResourceLocale(new Locale(localeInfo.get(0), localeInfo.get(1))); } return new ResourceLocale(new Locale(external)); } ResourceLocale(Locale locale); static IResourceLocale fromExternal(String external); @Override Locale getLocale(); @Override String toExternal(); @Override List<IResourceLocale> getLocaleFallback();  }
@Test public void testWarResourceLocale() { IResource resource = ResourceFactory.createResource("/js/sample/sample.js"); Assert.assertEquals("document.write(\"this is sample.js<br>\");", new String(resource.getOriginalContent())); ResourceRuntimeContext.ctx().setLocale(ResourceLocale.fromExternal("de_DE")); resource = ResourceFactory.createResource("/js/sample/sample.js"); Assert.assertEquals("document.write(\"this is de_DE sample.js<br>\");", new String(resource.getOriginalContent())); }
@Test public void testSharedResourceLocale() { IResource resource = ResourceFactory.createLibraryResource("/js/sample/sample1.js"); Assert.assertEquals("document.write('this is shared sample1.js<br>');", new String(resource.getOriginalContent())); ResourceRuntimeContext.ctx().setLocale(ResourceLocale.fromExternal("de_DE")); resource = ResourceFactory.createLibraryResource("/js/sample/sample1.js"); Assert.assertEquals("document.write('this is shared sample1.js<br>');", new String(resource.getOriginalContent())); }