mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
Don't use the real Briar directory for unit tests.
This commit is contained in:
@@ -23,8 +23,11 @@ public interface I18n {
|
||||
/** 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 dir) throws IOException;
|
||||
void saveLocale(File f) throws IOException;
|
||||
|
||||
/** Returns the ComponentOrientation of the current i18n locale. */
|
||||
ComponentOrientation getComponentOrientation();
|
||||
|
||||
@@ -122,22 +122,21 @@ public class I18nImpl implements I18n {
|
||||
}
|
||||
|
||||
public void loadLocale() throws IOException {
|
||||
loadLocale(FileUtils.getBriarDirectory());
|
||||
loadLocale(new File(FileUtils.getBriarDirectory(), "Data/locale.cfg"));
|
||||
}
|
||||
|
||||
public void loadLocale(File dir) throws IOException {
|
||||
Scanner s = new Scanner(new File(dir, "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(FileUtils.getBriarDirectory());
|
||||
saveLocale(new File(FileUtils.getBriarDirectory(), "Data/locale.cfg"));
|
||||
}
|
||||
|
||||
public void saveLocale(File dir) throws IOException {
|
||||
File localeCfg = new File(dir, "Data/locale.cfg");
|
||||
FileOutputStream out = new FileOutputStream(localeCfg);
|
||||
public void saveLocale(File f) throws IOException {
|
||||
FileOutputStream out = new FileOutputStream(f);
|
||||
PrintStream print = new PrintStream(out);
|
||||
print.println(locale);
|
||||
print.flush();
|
||||
|
||||
@@ -46,7 +46,7 @@ public class I18nTest extends TestCase {
|
||||
assertEquals("foo", i18n.tr("FOO"));
|
||||
i18n.setLocale(Locale.FRANCE);
|
||||
assertEquals("le foo", i18n.tr("FOO"));
|
||||
i18n.setLocale(Locale.CHINA); // No translation - use defaul
|
||||
i18n.setLocale(Locale.CHINA); // No translation - use default
|
||||
assertEquals("foo", i18n.tr("FOO"));
|
||||
}
|
||||
|
||||
@@ -83,13 +83,13 @@ public class I18nTest extends TestCase {
|
||||
@Test
|
||||
public void testSaveAndLoadLocale() throws IOException {
|
||||
testDir.mkdirs();
|
||||
new File(testDir, "Data").mkdir();
|
||||
File f = new File(testDir, "locale.cfg");
|
||||
i18n.setLocale(new Locale("fr"));
|
||||
assertEquals("le foo", i18n.tr("FOO"));
|
||||
i18n.saveLocale();
|
||||
i18n.saveLocale(f);
|
||||
i18n.setLocale(new Locale("zh")); // No translation - use default
|
||||
assertEquals("foo", i18n.tr("FOO"));
|
||||
i18n.loadLocale();
|
||||
i18n.loadLocale(f);
|
||||
assertEquals("le foo", i18n.tr("FOO"));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user