use of com.android.tools.idea.rendering.Locale in project android by JetBrains.
the class LocaleRenderer method getTableCellRendererComponent.
@NotNull
@Override
public Component getTableCellRendererComponent(@NotNull JTable table, @NotNull Object value, boolean selected, boolean focused, int row, int column) {
Component component = myRenderer.getTableCellRendererComponent(table, value, selected, focused, row, column);
if (component instanceof JLabel) {
Locale locale = myModel.getLocale(column);
assert locale != null;
((JLabel) component).setIcon(locale.getFlagImage());
}
return component;
}
use of com.android.tools.idea.rendering.Locale in project android by JetBrains.
the class StringResourceDataTest method testEditingCdata.
public void testEditingCdata() {
final Locale locale = Locale.create("en-rIN");
final String key = "key1";
String currentData = data.getStringResource(key).getTranslationAsString(locale);
assertEquals("<![CDATA[\n" + " <b>Google I/O 2014</b><br>\n" + " Version %s<br><br>\n" + " <a href=\"http://www.google.com/policies/privacy/\">Privacy Policy</a>\n" + " ]]>", currentData);
assertTrue(data.setTranslation(key, locale, currentData.replace("%s", "%1$s")));
final String expected = "<![CDATA[\n" + " <b>Google I/O 2014</b><br>\n" + " Version %1$s<br><br>\n" + " <a href=\"http://www.google.com/policies/privacy/\">Privacy Policy</a>\n" + " ]]>";
assertEquals(expected, data.getStringResource(key).getTranslationAsString(locale));
VirtualFile file = resourceDirectory.findFileByRelativePath("values-en-rIN/strings.xml");
assert file != null;
XmlTag tag = getNthXmlTag(file, 0);
assertEquals("key1", tag.getAttributeValue(SdkConstants.ATTR_NAME));
assertEquals(expected, tag.getValue().getText());
}
use of com.android.tools.idea.rendering.Locale in project android by JetBrains.
the class StringResourceDataTest method testRegionQualifier.
public void testRegionQualifier() {
Locale en_rGB = Locale.create("en-rGB");
assertTrue(data.getStringResource("key4").isTranslationMissing(en_rGB));
assertFalse(data.getStringResource("key3").isTranslationMissing(en_rGB));
assertFalse(data.getStringResource("key8").isTranslationMissing(en_rGB));
}
use of com.android.tools.idea.rendering.Locale in project android by JetBrains.
the class StringResourceDataTest method testEditingXliff.
public void testEditingXliff() {
String key = "key3";
Locale locale = Locale.create("en-rIN");
String currentData = data.getStringResource(key).getTranslationAsString(locale);
assertEquals("start <xliff:g>middle1</xliff:g>%s<xliff:g>middle3</xliff:g> end", currentData);
assertTrue(data.setTranslation(key, locale, currentData.replace("%s", "%1$s")));
String expected = "start <xliff:g>middle1</xliff:g>%1$s<xliff:g>middle3</xliff:g> end";
assertEquals(expected, data.getStringResource(key).getTranslationAsString(locale));
VirtualFile file = resourceDirectory.findFileByRelativePath("values-en-rIN/strings.xml");
assert file != null;
XmlTag tag = getNthXmlTag(file, 2);
assertEquals("key3", tag.getAttributeValue(SdkConstants.ATTR_NAME));
assertEquals(expected, tag.getValue().getText().trim());
}
Aggregations