NetBeans Rich Client Platform
Branding & Internationalisation
NetBeans Rich Client PlatformBranding & Internationalisation
Anton EppleEppleton IT Consulting
NetBeans Rich Client Platform
Agenda
InternationalisationBranding
Accessibility
NetBeans Rich Client Platform
Branding & Internationalisation
Internationalisable Resources:
String values in source files
String values in manifest
Help pages
Graphics
Files
Layer.xml ( e.g. Folders)
NetBeans Rich Client Platform
Branding & Internationalisation
NbBundle:
Similar to java.util.PropertyResourceBundle
Extends the functionality of the default Java resource support
Better Integration with Module System (multiple classloaders)
nbresloc protocol for localized files
NetBeans Rich Client Platform
Branding & Internationalisation
Text constants in Source Files:
Special ResourceBundle: NbBundle
Bundle.properties File in package:
Call from Java:
CTL_MyTopComponent = My WindowNachricht_Parameter = This is my {0}. Window
ResourceBundle bundle = NbBundle.getBundle(MyTopComponent.class);String msg = bundle.getString(„CTL_MyTopComponent“);// oderString msg = NbBundle.getMessage(MyTopComponent.class, „CTL_MyTopComponent“);// bis zu 3 Einzel ParameterString msg = NbBundle.getMessage(MyTopComponent.class, „Nachricht_Parameter“, New Integer(3));
NetBeans Rich Client Platform
Branding & Internationalisation
Externalize String Constants to .properties Files
Tools → Internationalization → Internationalization Wizard
NetBeans Rich Client Platform
Branding & Internationalisation
String values in manifests
Manifest file:
Bundle.properties:
Bundle_de.properties Datei:
Manifest-Version: 1.0OpenIDE-Module: de.eppleton.languageOpenIDE-Module-Localizing-Bundle: de/eppleton/language/Bundle.properties
OpenIDE-Module-Name=Language Switch
OpenIDE-Module-Name=Sprach Wechsel
NetBeans Rich Client Platform
Branding & Internationalisation
Search order:
Locale US:
1. Bundle_en_US.properties
2. Bundle_en.properties
3. Bundle.properties
NetBeans Rich Client Platform
Branding & Internationalisation
Other Resources:
Help Pages: Attach locale-extension ( _de ) to resources (html files, etc.)
Load graphics via localised String, or use extension (icon.gif, icon_de.gif):
System FileSystem (Menu):
Folder Attribute SystemFileSystem.localizingBundle
Image img = Utilities.loadImage(„resources/icon.gif“, true);
NetBeans Rich Client Platform
Branding & Internationalisation
nbresloc Protocol
Load localized Version of File:
Can load resources from all Modules:
also be used to reduce redundancy e.g. central repository for icons
URL u = new URL(„nbresloc:/de/eppleton/netbeans/modules/icon.png“);ImageIcon icon = newImageIcon(u);
NetBeans Rich Client Platform
Branding & Internationalisation
Bundling localization resources in Folder „locale“:
Example NetBeans platform9 Modules:
NetBeans Rich Client Platform
Branding & Internationalisation
Simplify Localization by externalizing defaults:
Translator sees only localizable resources:
NetBeans Rich Client Platform
Branding & Internationalisation
Localisation Bundles as Modules:
Localization can also be packaged as installable Plugin
User can install Language pack for his Locale:
http://www.sepix.de/blogs/blogrittner/blog/archive/2008/august/07/beandev_platform_uebersetzung_als_plugin/index.html
http://blogs.kiyut.com/tonny/2008/08/06/netbeans-platform-localization-as-plugins/
NetBeans Rich Client Platform
Branding & Internationalisation
OmegaT Translation Tool:
http://sf.net/projects/omegat/http://translatedfiles.netbeans.org/docs/HOWTOs/How-to-translate-NetBeans-using-OmegaT.html
NetBeans Rich Client Platform
Branding & Internationalisation
Change language on-the-fly (1): MenuItems
Not officially supported (but useful for Support → zh_CN)
but most MenuItems react to changing Locale:
Some don't (SaveAsAction):
public String getName() { return NbBundle.getMessage(SaveAction.class, "Save"); }
AbstractAction instance = Lookups.forPath("Actions/System").lookup(AbstractAction.class);instance.putValue(Action.NAME, NbBundle.getMessage(DataObject.class, "CTL_SaveAsAction"));
NetBeans Rich Client Platform
Branding & Internationalisation
Change language on-the-fly (2): Menus
1. Possibility: MenuBarFrame main = WindowManager.getDefault().getMainWindow();assert main != null;if (main instanceof JFrame) { Component [] c = ((Jframe)main).getJMenuBar().getComponents(); [....](Jmenu)c[i].setText(„internationalisiert...“); } // Error-prone...
NetBeans Rich Client Platform
Branding & Internationalisation
2. Possibility: Force Refresh
Demo
FileSystem sfs = Repository.getDefault().getDefaultFileSystem();FileObject menus = sfs.findResource("Menu"); FileObject[] children = menus.getChildren(); for (int i = 0; i < children.length; i++) { FileObject fileObject = children[i]; FileLock lock = null; try { lock = fileObject.lock(); String oldname= fileObject.getName(); fileObject.rename(lock, File.createTempFile("bla", "bla").getName(), null); fileObject.rename(lock, oldname, null); } catch (FileAlreadyLockedException es) { } lock.releaseLock();}
NetBeans Rich Client Platform
Agenda
InternationalisationBranding
Accessibility
NetBeans Rich Client Platform
Einfaches Branding einer Anwendung
Properties Dialog:
NetBeans Rich Client Platform
Basic Branding
Properties Dialog:
NetBeans Rich Client Platform
Basic Branding
Properties Dialog:
NetBeans Rich Client Platform
Replacing Icons
Find Resources:
Use „This layer in context“ to find module of an Action
Identify Icon Path in Source Files
Put in Suite's branding Folder
in a folder named like the module
JAR, under the same package:
NetBeans Rich Client Platform
Replacing Icons
Even Icons that don't exist in the original can be „replaced“ for a better Look & Feel
Example add rollover or disabled icons:
NetBeans Rich Client Platform
Replacing Icons
Picture Formats
What to do when your Icon collection has different Picture Format (e.g. gif instead png required)?
Rename your image.png to image.gif
No conversion needed
NetBeans Rich Client Platform
Branding von Texten
Branding token:
NetBeans Rich Client Platform
Branding Strings
Branding token is used in addition to locale
Resources stored in „locale“ folder
Search order example, Locale US:
1. Bundle_token_en_US.properties
2. Bundle_token_en.properties
3. Bundle_token.properties
4. Bundle_en_US.properties
5. Bundle_en.properties
6. Bundle.properties
NetBeans Rich Client Platform
Look & Feel
Dynamically changing Swing L&F at Runtime
Need to get Hold of Application Frame:UIManager.setLookAndFeel(new MetalLookAndFeel());
Frame frame = WindowManager.getDefault().getMainWindow();
SwingUtilities.updateComponentTreeUI(frame);
frame.pack();
UIDelegates need (e.g. Tabs) to be available or created for Third-party L&F (e.g. Synthetica, Substance)
NetBeans Rich Client Platform
Agenda
InternationalisationBranding
Accessibility
NetBeans Rich Client Platform
Accessibility
Resources:
http://a11y.netbeans.org/
a11y Checker Module:
This module checks designed forms online, in design time.
Provides sortable error list
Highlights affected components
Assists with fixes
Cooperates with i18n
NetBeans Rich Client Platform
Accessibility
Top Related