Пример #1
0
  @Test
  public void testMoveKeyTask() {
    if (I18nModule.isTransToolEnabled()) {
      prepareDevToolTests();
      Locale testLocale = i18nMgr.getLocaleOrDefault("de");
      String ktm = "key.to.move";
      i18nMgr.setCachingEnabled(true);
      Properties sourcePropResolved = i18nMgr.getResolvedProperties(testLocale, testSourceBundle);
      Properties sourceProp =
          i18nMgr.getPropertiesWithoutResolvingRecursively(testLocale, testSourceBundle);
      String matchString = sourceProp.getProperty(ktm);
      assertTrue(sourcePropResolved.getProperty("key.to.stay2").indexOf(matchString) != -1);

      tDMgr.moveKeyToOtherBundle(testSourceBundle, testTargetBundle, ktm);
      sourceProp = i18nMgr.getPropertiesWithoutResolvingRecursively(testLocale, testSourceBundle);
      Properties targetProp =
          i18nMgr.getPropertiesWithoutResolvingRecursively(testLocale, testTargetBundle);
      assertNull(sourceProp.getProperty(ktm));
      assertNotNull(targetProp.getProperty(ktm));
      Properties sourceMetaProp =
          i18nMgr.getPropertiesWithoutResolvingRecursively(null, testSourceBundle);
      Properties targetMetaProp =
          i18nMgr.getPropertiesWithoutResolvingRecursively(null, testTargetBundle);
      assertNull(sourceMetaProp.getProperty(ktm + I18nManager.METADATA_ANNOTATION_POSTFIX));
      assertNull(sourceMetaProp.getProperty(ktm + I18nManager.METADATA_KEY_PRIORITY_POSTFIX));
      assertTrue(targetMetaProp.containsKey(ktm + I18nManager.METADATA_ANNOTATION_POSTFIX));
      assertEquals(
          "100", targetMetaProp.getProperty(ktm + I18nManager.METADATA_KEY_PRIORITY_POSTFIX));
      // check for changed references in value
      // if correctly done, should still be resolvable
      assertTrue(sourcePropResolved.getProperty("key.to.stay2").indexOf(matchString) != -1);
    }
  }
Пример #2
0
 public void movePackageByMovingSingleKeysTask(String originBundleName, String targetBundleName) {
   Properties properties =
       i18nMgr.getPropertiesWithoutResolvingRecursively(
           I18nModule.getFallbackLocale(), originBundleName);
   Set<Object> keys = properties.keySet();
   for (Object keyObj : keys) {
     String key = (String) keyObj;
     moveKeyToOtherBundle(originBundleName, targetBundleName, key);
   }
 }