diff --git a/i18n/DroidSansFallback.ttf b/i18n/DroidSansFallback.ttf deleted file mode 100644 index 61460b1f9df674885ff4048253a37ef68e986bae..0000000000000000000000000000000000000000 Binary files a/i18n/DroidSansFallback.ttf and /dev/null differ diff --git a/i18n/Padauk.ttf b/i18n/Padauk.ttf deleted file mode 100644 index cd1d113d3ebfb14ec514c43a50c436022601dd07..0000000000000000000000000000000000000000 Binary files a/i18n/Padauk.ttf and /dev/null differ diff --git a/i18n/TibetanMachineUni.ttf b/i18n/TibetanMachineUni.ttf deleted file mode 100644 index d9e1899fc9f6a7ba70ff46a949b02d4b3991e3e0..0000000000000000000000000000000000000000 Binary files a/i18n/TibetanMachineUni.ttf and /dev/null differ diff --git a/i18n/i18n.properties b/i18n/i18n.properties deleted file mode 100644 index 2e7329e2986f080c3d2c5d10ff71e576c9224bb4..0000000000000000000000000000000000000000 --- a/i18n/i18n.properties +++ /dev/null @@ -1,73 +0,0 @@ -BACK=Back -NEXT=Next -CANCEL=Cancel -FINISH=Finish - -YES=Yes -NO=No -UNKNOWN=Unknown - -CANCELLING=Cancelling, please wait... - -ENCRYPTING_FILE=Encrypting file: -EXTRACTING_FILE=Extracting file: -COPYING_FILE=Copying file: - -DIRECTORY_NOT_FOUND=The chosen folder was not found: -FILE_NOT_DIRECTORY=The chosen location is not a folder: -DIRECTORY_NOT_ALLOWED=You do not have permission to use the chosen folder: - -WINDOWS=Windows -MAC=Macintosh -LINUX=Linux - -ENTER_PASSWORD=Enter password: -CONFIRM_PASSWORD=Confirm password: - -INVITATION_TITLE=Create Invitation -INVITATION_INTRO=\ -This wizard will guide you through the process of inviting a new contact to \ -join Briar. <p><p>\ -The wizard will create some files that you must give to your contact. <p><p>\ -You will also be asked to choose a password, which your contact will use to \ -unlock the invitation. -INVITATION_EXISTING_USER=Does your contact already use Briar? -INVITATION_OPERATING_SYSTEM=What kind of computer does your contact use? -INVITATION_PASSWORD=\ -Please choose a password for the invitation. <p><p>\ -Your contact will need this password to unlock the invitation. <p><p>\ -It is very important that you DO NOT send this password across the internet \ -or by SMS. -INVITATION_LOCATION_TEXT=\ -Please choose where to save the invitation files. <p><p>\ -It is recommended to save them on a removable device such as a USB stick. \ -Alternatively, you can send them to your contact by Bluetooth. <p><p>\ -Please press Next to choose a location. -INVITATION_LOCATION_TITLE=Save Invitation Files -INVITATION_PROGRESS_BEGIN=Preparing to create invitation... -INVITATION_CREATED=The following files have been created: -INVITATION_GIVE_TO_CONTACT=\ -Please give these files and the password to your contact. -INVITATION_ERROR=An error occurred while creating the invitation: -INVITATION_ABORTED=The invitation could not be not created. - -SETUP_TITLE=Setup -SETUP_LANGUAGE=\ -Welcome to the setup program for Briar, a secure news and discussion \ -network. <p><p>\ -Please choose a language and press Next to begin the installation. -SETUP_ALREADY_INSTALLED=Are you already a user of Briar? -SETUP_INSTRUCTIONS=\ -To accept the person who sent you this invitation as a contact, please open \ -the invitation.dat file in Briar by selecting File > Open from the menu, or \ -by dragging the file onto the Briar window. -SETUP_LOCATION_TEXT=\ -It is recommended to install Briar on a removable device such as a USB \ -stick. <p><p>\ -Please press Next to choose the folder where Briar will be installed. -SETUP_LOCATION_TITLE=Choose Folder -SETUP_PROGRESS_BEGIN=Preparing to install... -SETUP_INSTALLED=Briar has been installed in the following folder: -SETUP_UNINSTALL=To uninstall Briar, simply delete the folder. -SETUP_ERROR=An error occurred while installing: -SETUP_ABORTED=The installation could not be completed. diff --git a/i18n/i18n_bo.properties b/i18n/i18n_bo.properties deleted file mode 100644 index 77bd11893982ed22d90fef9154ea9951fa02573b..0000000000000000000000000000000000000000 --- a/i18n/i18n_bo.properties +++ /dev/null @@ -1,2 +0,0 @@ -# Note: It seems to be necessary to insert a zero-width space (\u200b) after -# every inter-word dot (\u0f0b) to allow line-breaking. diff --git a/i18n/net/sf/briar/api/i18n/FontManager.java b/i18n/net/sf/briar/api/i18n/FontManager.java deleted file mode 100644 index b1bd3a1fb0236b97db9977a1d709d46e1d01e404..0000000000000000000000000000000000000000 --- a/i18n/net/sf/briar/api/i18n/FontManager.java +++ /dev/null @@ -1,23 +0,0 @@ -package net.sf.briar.api.i18n; - -import java.awt.Font; -import java.io.File; -import java.util.Locale; - -public interface FontManager { - - /** - * Initializes the FontManager for the given locale. Fonts are loaded from - * the given directory if they cannot be loaded from the running jar. - */ - void initialize(Locale locale, File dir); - - /** Returns the appropriate font for the given language. */ - Font getFontForLanguage(String language); - - /** Returns the current user interface font. */ - Font getUiFont(); - - /** Sets the user interface font appropriately for the given language. */ - void setUiFontForLanguage(String language); -} \ No newline at end of file diff --git a/i18n/net/sf/briar/api/i18n/I18n.java b/i18n/net/sf/briar/api/i18n/I18n.java deleted file mode 100644 index ef8290c42753648b95be33982ebf343ea5860165..0000000000000000000000000000000000000000 --- a/i18n/net/sf/briar/api/i18n/I18n.java +++ /dev/null @@ -1,53 +0,0 @@ -package net.sf.briar.api.i18n; - -import java.awt.ComponentOrientation; -import java.awt.Font; -import java.io.File; -import java.io.IOException; -import java.util.Locale; - -public interface I18n { - - /** Returns the named string, translated for the current i18n locale. */ - String tr(String name); - - /** Returns the i18n locale. This may not match the system locale. */ - Locale getLocale(); - - /** Sets the i18n locale. */ - void setLocale(Locale locale); - - /** Loads the i18n locale from Briar/Data/locale.cfg. */ - void loadLocale() throws IOException; - - /** Saves the i18n locale to Briar/Data/locale.cfg. */ - void saveLocale() throws IOException; - - /** Loads the i18n locale from the given file. */ - void loadLocale(File f) throws IOException; - - /** Saves the i18n locale to the given file. */ - void saveLocale(File f) throws IOException; - - /** Returns the ComponentOrientation of the current i18n locale. */ - ComponentOrientation getComponentOrientation(); - - /** Registers a listener for changes to the i18n locale. */ - void addListener(Listener l); - - /** Unregisters a listener for changes to the i18n locale. */ - void removeListener(Listener l); - - /** - * Implemented by classes that wish to be informed of changes to the i18n - * locale. - */ - public interface Listener { - - /** - * Called whenever the i18n locale changes. - * @param uiFont The user interface font for the new locale. - */ - void localeChanged(Font uiFont); - } -} \ No newline at end of file diff --git a/i18n/net/sf/briar/api/i18n/Stri18ng.java b/i18n/net/sf/briar/api/i18n/Stri18ng.java deleted file mode 100644 index a15305b3175d1fdd131a18dc1501d1730b8ad6de..0000000000000000000000000000000000000000 --- a/i18n/net/sf/briar/api/i18n/Stri18ng.java +++ /dev/null @@ -1,49 +0,0 @@ -package net.sf.briar.api.i18n; - -/** A named translatable string. */ -public class Stri18ng { - - private static final String HTML_OPEN_LEFT = "<html><body align='left'>"; - private static final String HTML_OPEN_RIGHT = "<html><body align='right'>"; - private static final String HTML_CLOSE = "</body></html>"; - private static final String PARAGRAPH = "<p><p>"; // Yes, two of them - - private final String name; - private final I18n i18n; - - public Stri18ng(String name, I18n i18n) { - this.name = name; - this.i18n = i18n; - } - - /** Returns the string translated for the current i18n locale. */ - public String tr() { - return i18n.tr(name); - } - - /** Returns the string, translated for the current i18n locale, as HTML. */ - public String html() { - if(i18n.getComponentOrientation().isLeftToRight()) - return HTML_OPEN_LEFT + i18n.tr(name) + HTML_CLOSE; - else return HTML_OPEN_RIGHT + i18n.tr(name) + HTML_CLOSE; - } - - /** - * Returns the string, translated for the current locale, as HTML. - * @param paras Additional (pre-translated) paragraphs that should be - * appended to the HTML. - */ - public String html(String... paras) { - StringBuilder s = new StringBuilder(); - if(i18n.getComponentOrientation().isLeftToRight()) - s.append(HTML_OPEN_LEFT); - else s.append(HTML_OPEN_RIGHT); - s.append(tr()); - for(String para : paras) { - s.append(PARAGRAPH); - s.append(para); - } - s.append(HTML_CLOSE); - return s.toString(); - } -} diff --git a/i18n/net/sf/briar/i18n/FontManagerImpl.java b/i18n/net/sf/briar/i18n/FontManagerImpl.java deleted file mode 100644 index ad0c0b2223ff5d34bec1c5de6fc582b23e6b264c..0000000000000000000000000000000000000000 --- a/i18n/net/sf/briar/i18n/FontManagerImpl.java +++ /dev/null @@ -1,108 +0,0 @@ -package net.sf.briar.i18n; - -import java.awt.Font; -import java.awt.FontFormatException; -import java.awt.font.TextAttribute; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; -import java.util.logging.Level; -import java.util.logging.Logger; - -import javax.swing.UIManager; - -import net.sf.briar.api.i18n.FontManager; - -// Needs to be public for installer -public class FontManagerImpl implements FontManager { - - private static final Logger LOG = - Logger.getLogger(FontManagerImpl.class.getName()); - - /** - * Each bundled font is associated with a size, which is meant to occupy - * roughly the same amount of space as the default font (12 point sans), - * and a list of languages for which the bundled font should be used. - */ - private static final BundledFont[] BUNDLED_FONTS = { - // Use TibetanMachineUni for Tibetan - new BundledFont("TibetanMachineUni.ttf", 14f, new String[] { "bo" }), - // Use Padauk for Burmese - new BundledFont("Padauk.ttf", 14f, new String[] { "my" }), - // Use DroidSansFallback for Chinese, Japanese and Korean - new BundledFont("DroidSansFallback.ttf", 12f, - new String[] { "zh" , "ja", "ko" }) - }; - - // Map from languages to fonts - private final Map<String, Font> fonts = new HashMap<String, Font>(); - - private volatile Font defaultFont = null, uiFont = null; - - public void initialize(Locale locale, File dir) { - // Look for bundled fonts in the jar and the filesystem. If any fonts - // are missing or fail to load, fall back to the default font. - ClassLoader loader = getClass().getClassLoader(); - for(BundledFont bf : BUNDLED_FONTS) { - try { - InputStream in = loader.getResourceAsStream(bf.filename); - if(in == null) - in = new FileInputStream(new File(dir, bf.filename)); - Font font = Font.createFont(Font.TRUETYPE_FONT, in); - font = font.deriveFont(bf.size); - for(String language : bf.languages) fonts.put(language, font); - } catch(FontFormatException e) { - if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString()); - } catch(IOException e) { - if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString()); - } - } - defaultFont = getFont("Sans", 12f); - assert defaultFont != null; // FIXME: This is failing on Windows - setUiFontForLanguage(locale.getLanguage()); - } - - private Font getFont(String name, float size) { - Map<TextAttribute, Object> attr = new HashMap<TextAttribute, Object>(); - attr.put(TextAttribute.FAMILY, name); - attr.put(TextAttribute.SIZE, Float.valueOf(size)); - return Font.getFont(attr); - } - - public Font getFontForLanguage(String language) { - assert defaultFont != null; - Font font = fonts.get(language); - return font == null ? defaultFont : font; - } - - public Font getUiFont() { - return uiFont; - } - - public void setUiFontForLanguage(String language) { - uiFont = getFontForLanguage(language); - Enumeration<Object> keys = UIManager.getDefaults().keys(); - while(keys.hasMoreElements()) { - Object key = keys.nextElement(); - if(UIManager.getFont(key) != null) UIManager.put(key, uiFont); - } - } - - private static class BundledFont { - - private final String filename; - private final float size; - private final String[] languages; - - private BundledFont(String filename, float size, String[] languages) { - this.filename = filename; - this.size = size; - this.languages = languages; - } - } -} diff --git a/i18n/net/sf/briar/i18n/FontManagerTest.java b/i18n/net/sf/briar/i18n/FontManagerTest.java deleted file mode 100644 index a86c688c945d064fb75faf25902e12e7333a347c..0000000000000000000000000000000000000000 --- a/i18n/net/sf/briar/i18n/FontManagerTest.java +++ /dev/null @@ -1,74 +0,0 @@ -package net.sf.briar.i18n; -import java.awt.Font; -import java.io.File; -import java.util.Locale; - -import net.sf.briar.BriarTestCase; -import net.sf.briar.TestUtils; -import net.sf.briar.api.i18n.FontManager; - -import org.junit.Test; - -public class FontManagerTest extends BriarTestCase { - - private final File fontDir = TestUtils.getFontDirectory(); - - @Test - public void testBundledFontsAreLoaded() { - FontManager fontManager = new FontManagerImpl(); - fontManager.initialize(Locale.UK, fontDir); - - Font font = fontManager.getFontForLanguage("en"); // English - assertEquals(12, font.getSize()); - - // The exact font names vary by platform, so just check how they start - font = fontManager.getFontForLanguage("bo"); // Tibetan - assertTrue(font.getFamily().startsWith("Tibetan")); - assertEquals(14, font.getSize()); - - font = fontManager.getFontForLanguage("my"); // Burmese - assertTrue(font.getFamily().startsWith("Padauk")); - assertEquals(14, font.getSize()); - } - - @Test - public void testInternationalCharactersCanBeDisplayed() { - FontManager fontManager = new FontManagerImpl(); - fontManager.initialize(Locale.UK, fontDir); - - Font font = fontManager.getFontForLanguage("en"); // English - assertTrue(font.canDisplay('a')); - - font = fontManager.getFontForLanguage("ar"); // Arabic - assertTrue(font.canDisplay('\u0627')); // An Arabic character - - font = fontManager.getFontForLanguage("bo"); // Tibetan - assertTrue(font.canDisplay('\u0f00')); // A Tibetan character - - font = fontManager.getFontForLanguage("fa"); // Persian - assertTrue(font.canDisplay('\ufb56')); // A Persian character - - font = fontManager.getFontForLanguage("my"); // Burmese - assertTrue(font.canDisplay('\u1000')); // A Burmese character - - font = fontManager.getFontForLanguage("zh"); // Chinese - assertTrue(font.canDisplay('\u4e00')); // A Chinese character - } - - @Test - public void testSetAndGetUiFont() { - FontManager fontManager = new FontManagerImpl(); - fontManager.initialize(Locale.UK, fontDir); - Font font = fontManager.getUiFont(); - assertEquals(12, font.getSize()); - - fontManager.setUiFontForLanguage("bo"); - font = fontManager.getUiFont(); - assertTrue(font.getFamily().startsWith("Tibetan")); - assertEquals(14, font.getSize()); - - fontManager.setUiFontForLanguage("en"); - font = fontManager.getUiFont(); - assertEquals(12, font.getSize()); - } -} diff --git a/i18n/net/sf/briar/i18n/I18nImpl.java b/i18n/net/sf/briar/i18n/I18nImpl.java deleted file mode 100644 index ca541eaa28f3f157b83dfa51a9456f25fabfd097..0000000000000000000000000000000000000000 --- a/i18n/net/sf/briar/i18n/I18nImpl.java +++ /dev/null @@ -1,165 +0,0 @@ -package net.sf.briar.i18n; - -import java.awt.ComponentOrientation; -import java.awt.Font; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.PrintStream; -import java.util.Collection; -import java.util.Locale; -import java.util.MissingResourceException; -import java.util.ResourceBundle; -import java.util.Scanner; -import java.util.concurrent.CopyOnWriteArrayList; -import java.util.logging.Level; -import java.util.logging.Logger; - -import javax.swing.UIManager; - -import net.sf.briar.api.i18n.FontManager; -import net.sf.briar.api.i18n.I18n; -import net.sf.briar.util.FileUtils; - -import com.google.inject.Inject; - -// Needs to be public for installer -public class I18nImpl implements I18n { - - /** - * Property keys for strings used in the JRE's built-in dialogs. Values - * assigned to these keys in i18n properties files will override the - * built-in values. - */ - private static final String[] uiManagerKeys = { - "FileChooser.acceptAllFileFilterText", - "FileChooser.cancelButtonText", - "FileChooser.cancelButtonToolTipText", - "FileChooser.detailsViewButtonAccessibleName", - "FileChooser.detailsViewButtonToolTipText", - "FileChooser.directoryOpenButtonText", - "FileChooser.directoryOpenButtonToolTipText", - "FileChooser.fileAttrHeaderText", - "FileChooser.fileDateHeaderText", - "FileChooser.fileNameHeaderText", - "FileChooser.fileNameLabelText", - "FileChooser.fileSizeHeaderText", - "FileChooser.filesOfTypeLabelText", - "FileChooser.fileTypeHeaderText", - "FileChooser.helpButtonText", - "FileChooser.helpButtonToolTipText", - "FileChooser.homeFolderAccessibleName", - "FileChooser.homeFolderToolTipText", - "FileChooser.listViewButtonAccessibleName", - "FileChooser.listViewButtonToolTipText", - "FileChooser.lookInLabelText", - "FileChooser.newFolderErrorText", - "FileChooser.newFolderToolTipText", - "FileChooser.openButtonText", - "FileChooser.openButtonToolTipText", - "FileChooser.openDialogTitleText", - "FileChooser.saveButtonText", - "FileChooser.saveButtonToolTipText", - "FileChooser.saveDialogTitleText", - "FileChooser.saveInLabelText", - "FileChooser.updateButtonText", - "FileChooser.updateButtonToolTipText", - "FileChooser.upFolderAccessibleName", - "FileChooser.upFolderToolTipText", - "OptionPane.cancelButtonText", - "OptionPane.noButtonText", - "OptionPane.yesButtonText", - "ProgressMonitor.progressText" - }; - - private static final Logger LOG = - Logger.getLogger(I18nImpl.class.getName()); - - private final Object bundleLock = new Object(); - private final ClassLoader loader = I18n.class.getClassLoader(); - private final Collection<Listener> listeners = - new CopyOnWriteArrayList<Listener>(); - private final FontManager fontManager; - - private volatile Locale locale = Locale.getDefault(); - private volatile ResourceBundle bundle = null; - - @Inject - public I18nImpl(FontManager fontManager) { - this.fontManager = fontManager; - } - - public String tr(String name) { - loadResourceBundle(); - return bundle.getString(name); - } - - private void loadResourceBundle() { - if(bundle == null) { - synchronized(bundleLock) { - if(bundle == null) { - bundle = ResourceBundle.getBundle("i18n", locale, loader); - assert bundle != null; - for(String key : uiManagerKeys) { - try { - UIManager.put(key, bundle.getString(key)); - } catch(MissingResourceException e) { - if(LOG.isLoggable(Level.WARNING)) - LOG.warning(e.toString()); - } - } - } - } - } - } - - public Locale getLocale() { - return locale; - } - - public void setLocale(Locale locale) { - fontManager.setUiFontForLanguage(locale.getLanguage()); - Font uiFont = fontManager.getUiFont(); - synchronized(bundleLock) { - this.locale = locale; - Locale.setDefault(locale); - bundle = null; - for(Listener l : listeners) l.localeChanged(uiFont); - } - } - - public void loadLocale() throws IOException { - loadLocale(new File(FileUtils.getBriarDirectory(), "Data/locale.cfg")); - } - - public void loadLocale(File f) throws IOException { - Scanner s = new Scanner(f); - if(s.hasNextLine()) setLocale(new Locale(s.nextLine())); - s.close(); - } - - public void saveLocale() throws IOException { - saveLocale(new File(FileUtils.getBriarDirectory(), "Data/locale.cfg")); - } - - public void saveLocale(File f) throws IOException { - FileOutputStream out = new FileOutputStream(f); - PrintStream print = new PrintStream(out); - print.println(locale); - print.flush(); - print.close(); - } - - public ComponentOrientation getComponentOrientation() { - return ComponentOrientation.getOrientation(locale); - } - - public void addListener(Listener l) { - l.localeChanged(fontManager.getUiFont()); - listeners.add(l); - } - - public void removeListener(Listener l) { - listeners.remove(l); - } -} diff --git a/i18n/net/sf/briar/i18n/I18nModule.java b/i18n/net/sf/briar/i18n/I18nModule.java deleted file mode 100644 index 1c51259d6ec14c9c11325c35b3284fd19187a4fe..0000000000000000000000000000000000000000 --- a/i18n/net/sf/briar/i18n/I18nModule.java +++ /dev/null @@ -1,16 +0,0 @@ -package net.sf.briar.i18n; - -import net.sf.briar.api.i18n.FontManager; -import net.sf.briar.api.i18n.I18n; - -import com.google.inject.AbstractModule; -import com.google.inject.Singleton; - -public class I18nModule extends AbstractModule { - - @Override - protected void configure() { - bind(FontManager.class).to(FontManagerImpl.class).in(Singleton.class); - bind(I18n.class).to(I18nImpl.class).in(Singleton.class); - } -} diff --git a/i18n/net/sf/briar/i18n/I18nTest.java b/i18n/net/sf/briar/i18n/I18nTest.java deleted file mode 100644 index d5f3f36a20257579eaf28758ce4813efc0b63883..0000000000000000000000000000000000000000 --- a/i18n/net/sf/briar/i18n/I18nTest.java +++ /dev/null @@ -1,98 +0,0 @@ -package net.sf.briar.i18n; - -import java.awt.Font; -import java.io.File; -import java.io.IOException; -import java.util.Locale; - -import net.sf.briar.BriarTestCase; -import net.sf.briar.TestUtils; -import net.sf.briar.api.i18n.FontManager; -import net.sf.briar.api.i18n.I18n; - -import org.jmock.Expectations; -import org.jmock.Mockery; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -public class I18nTest extends BriarTestCase { - - private final File base = - new File(TestUtils.getBuildDirectory(), "i18n.properties"); - private final File french = - new File(TestUtils.getBuildDirectory(), "i18n_fr.properties"); - private final File testDir = TestUtils.getTestDirectory(); - - FontManager fontManager = null; - I18n i18n = null; - - @Before - public void setUp() throws IOException { - TestUtils.createFile(base, "FOO=foo\r\nBAR=bar\r\n"); - TestUtils.createFile(french, "FOO=le foo\r\nBAR=la bar\r\n"); - fontManager = new FontManagerImpl(); - fontManager.initialize(Locale.UK, TestUtils.getFontDirectory()); - i18n = new I18nImpl(fontManager); - } - - @Test - public void testTr() { - i18n.setLocale(Locale.UK); - assertEquals("foo", i18n.tr("FOO")); - i18n.setLocale(Locale.FRANCE); - assertEquals("le foo", i18n.tr("FOO")); - i18n.setLocale(Locale.CHINA); // No translation - use default - assertEquals("foo", i18n.tr("FOO")); - } - - @Test - public void testSettingLocaleAffectsComponentOrientation() { - i18n.setLocale(new Locale("en")); // English - assertTrue(i18n.getComponentOrientation().isLeftToRight()); - i18n.setLocale(new Locale("ar")); // Arabic - assertFalse(i18n.getComponentOrientation().isLeftToRight()); - } - - @Test - public void testListenersAreInformedOfLocaleChanges() { - final Font englishFont = fontManager.getFontForLanguage("en"); - final Font tibetanFont = fontManager.getFontForLanguage("bo"); - - Mockery context = new Mockery(); - final I18n.Listener listener = context.mock(I18n.Listener.class); - context.checking(new Expectations() {{ - // Listener should be called once when registered - oneOf(listener).localeChanged(englishFont); - // Listener should be called again when locale changes - oneOf(listener).localeChanged(tibetanFont); - }}); - - i18n.setLocale(new Locale("en")); - i18n.addListener(listener); - i18n.setLocale(new Locale("bo")); - i18n.removeListener(listener); - - context.assertIsSatisfied(); - } - - @Test - public void testSaveAndLoadLocale() throws IOException { - testDir.mkdirs(); - File f = new File(testDir, "locale.cfg"); - i18n.setLocale(new Locale("fr")); - assertEquals("le foo", i18n.tr("FOO")); - i18n.saveLocale(f); - i18n.setLocale(new Locale("zh")); // No translation - use default - assertEquals("foo", i18n.tr("FOO")); - i18n.loadLocale(f); - assertEquals("le foo", i18n.tr("FOO")); - } - - @After - public void tearDown() { - TestUtils.delete(base); - TestUtils.delete(french); - TestUtils.deleteTestDirectory(testDir); - } -}