Merge pull request #350 from marhali/incomplete-empty-translation-values
treat empty translation values as incomplete
This commit is contained in:
commit
ba10b078ea
@ -4,6 +4,9 @@
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Treat empty translation values (e.g. "") as incomplete
|
||||||
|
|
||||||
## [4.4.4] - 2023-12-11
|
## [4.4.4] - 2023-12-11
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
@ -48,7 +48,8 @@ public class TranslationUtil {
|
|||||||
* @return true if missing values were found otherwise false
|
* @return true if missing values were found otherwise false
|
||||||
*/
|
*/
|
||||||
public static boolean isIncomplete(@NotNull TranslationValue value, @NotNull TranslationData data) {
|
public static boolean isIncomplete(@NotNull TranslationValue value, @NotNull TranslationData data) {
|
||||||
return value.getLocaleContents().size() != data.getLocales().size();
|
return value.getLocaleContents().size() != data.getLocales().size()
|
||||||
|
|| value.getLocaleContents().stream().anyMatch(String::isEmpty);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
30
src/test/java/util/TranslationUtilTest.java
Normal file
30
src/test/java/util/TranslationUtilTest.java
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
package util;
|
||||||
|
|
||||||
|
import de.marhali.easyi18n.model.TranslationData;
|
||||||
|
import de.marhali.easyi18n.model.TranslationValue;
|
||||||
|
import de.marhali.easyi18n.util.TranslationUtil;
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class TranslationUtilTest {
|
||||||
|
@Test
|
||||||
|
public void isIncomplete() {
|
||||||
|
TranslationData data = new TranslationData(true);
|
||||||
|
|
||||||
|
data.addLocale("de");
|
||||||
|
data.addLocale("en");
|
||||||
|
|
||||||
|
TranslationValue complete = new TranslationValue();
|
||||||
|
complete.setLocaleValues(Map.of("de", "deValue", "en", "enValue"));
|
||||||
|
Assert.assertFalse(TranslationUtil.isIncomplete(complete, data));
|
||||||
|
|
||||||
|
TranslationValue missingLocale = new TranslationValue("de", "deValue");
|
||||||
|
Assert.assertTrue(TranslationUtil.isIncomplete(missingLocale, data));
|
||||||
|
|
||||||
|
TranslationValue emptyLocaleValue = new TranslationValue();
|
||||||
|
emptyLocaleValue.setLocaleValues(Map.of("de", "deValue", "en", ""));
|
||||||
|
Assert.assertTrue(TranslationUtil.isIncomplete(emptyLocaleValue, data));
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user