• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Branding & Internationalization with the NetBeans Platform
 

Branding & Internationalization with the NetBeans Platform

on

  • 12,190 views

How to brand and localize your NetBeans Platform application, including some tipps on how to change language on the fly and how to make your application accessible.

How to brand and localize your NetBeans Platform application, including some tipps on how to change language on the fly and how to make your application accessible.

Statistics

Views

Total Views
12,190
Views on SlideShare
11,934
Embed Views
256

Actions

Likes
0
Downloads
72
Comments
0

5 Embeds 256

http://eppleton.sharedhost.de 138
http://www.slideshare.net 58
http://eppleton.de 48
http://www.netbeanstraining.de 10
http://translate.googleusercontent.com 2

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Branding & Internationalization with the NetBeans Platform Branding & Internationalization with the NetBeans Platform Presentation Transcript

    • NetBeans Rich Client Platform Branding & Internationalisation NetBeans Rich Client Platform Branding & Internationalisation Anton Epple Eppleton IT Consulting
    • NetBeans Rich Client Platform Agenda Internationalisation Branding 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: CTL_MyTopComponent = My Window Nachricht_Parameter = This is my {0}. Window Call from Java: ResourceBundle bundle = NbBundle.getBundle(MyTopComponent.class); String msg = bundle.getString(„CTL_MyTopComponent“); // oder String msg = NbBundle.getMessage(MyTopComponent.class, „CTL_MyTopComponent“); // bis zu 3 Einzel Parameter String 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: Manifest-Version: 1.0 OpenIDE-Module: de.eppleton.language OpenIDE-Module-Localizing-Bundle: de/eppleton/language/Bundle.properties Bundle.properties: OpenIDE-Module-Name=Language Switch Bundle_de.properties Datei: 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): Image img = Utilities.loadImage(„resources/icon.gif“, true); • System FileSystem (Menu): Folder Attribute SystemFileSystem.localizingBundle
    • NetBeans Rich Client Platform Branding & Internationalisation nbresloc Protocol Load localized Version of File: URL u = new URL(„nbresloc:/de/eppleton/netbeans/modules/icon.png“); ImageIcon icon = newImageIcon(u); Can load resources from all Modules: also be used to reduce redundancy e.g. central repository for icons
    • 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/augu http://blogs.kiyut.com/tonny/2008/08/06/netbeans-platform-lo
    • NetBeans Rich Client Platform Branding & Internationalisation OmegaT Translation Tool: http://sf.net/projects/omegat/ http://translatedfiles.netbeans.org/docs/HOWTOs/How-to-trans
    • 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: public String getName() { return NbBundle.getMessage(SaveAction.class, "Save"); } Some don't (SaveAsAction): 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: MenuBar Frame 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 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();} Demo
    • NetBeans Rich Client Platform Agenda Internationalisation Branding 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 – Bundle_token_en.properties – 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 Internationalisation Branding 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