Java Code Examples for com.android.ide.common.resources.configuration.FolderConfiguration#getLocaleQualifier()
The following examples show how to use
com.android.ide.common.resources.configuration.FolderConfiguration#getLocaleQualifier() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TranslationDetector.java From javaide with GNU General Public License v3.0 | 6 votes |
/** Look up the language for the given folder name */ private static String getLanguageTag(String name) { if (FD_RES_VALUES.equals(name)) { return null; } FolderConfiguration configuration = FolderConfiguration.getConfigForFolder(name); if (configuration != null) { LocaleQualifier locale = configuration.getLocaleQualifier(); if (locale != null && !locale.hasFakeValue()) { return locale.getTag(); } } return null; }
Example 2
Source File: ResourceRepository.java From javaide with GNU General Public License v3.0 | 6 votes |
/** * Returns the sorted list of languages used in the resources. */ @NonNull public SortedSet<String> getLanguages() { ensureInitialized(); SortedSet<String> set = new TreeSet<String>(); Collection<List<ResourceFolder>> folderList = mFolderMap.values(); for (List<ResourceFolder> folderSubList : folderList) { for (ResourceFolder folder : folderSubList) { FolderConfiguration config = folder.getConfiguration(); LocaleQualifier locale = config.getLocaleQualifier(); if (locale != null) { set.add(locale.getLanguage()); } } } return set; }
Example 3
Source File: ResourceRepository.java From javaide with GNU General Public License v3.0 | 6 votes |
/** * Returns the sorted list of regions used in the resources with the given language. * @param currentLanguage the current language the region must be associated with. */ @NonNull public SortedSet<String> getRegions(@NonNull String currentLanguage) { ensureInitialized(); SortedSet<String> set = new TreeSet<String>(); Collection<List<ResourceFolder>> folderList = mFolderMap.values(); for (List<ResourceFolder> folderSubList : folderList) { for (ResourceFolder folder : folderSubList) { FolderConfiguration config = folder.getConfiguration(); // get the language LocaleQualifier locale = config.getLocaleQualifier(); if (locale != null && currentLanguage.equals(locale.getLanguage()) && locale.getRegion() != null) { set.add(locale.getRegion()); } } } return set; }
Example 4
Source File: ResourceRepository.java From NBANDROID-V2 with Apache License 2.0 | 6 votes |
/** * Returns the sorted list of languages used in the resources. */ @NonNull public SortedSet<String> getLanguages() { ensureInitialized(); SortedSet<String> set = new TreeSet<String>(); Collection<List<ResourceFolder>> folderList = mFolderMap.values(); for (List<ResourceFolder> folderSubList : folderList) { for (ResourceFolder folder : folderSubList) { FolderConfiguration config = folder.getConfiguration(); LocaleQualifier locale = config.getLocaleQualifier(); if (locale != null && locale.hasLanguage()) { set.add(locale.getLanguage()); } } } return set; }
Example 5
Source File: ResourceRepository.java From NBANDROID-V2 with Apache License 2.0 | 6 votes |
/** * Returns the sorted list of regions used in the resources with the given language. * * @param currentLanguage the current language the region must be associated with. */ @NonNull public SortedSet<String> getRegions(@NonNull String currentLanguage) { ensureInitialized(); SortedSet<String> set = new TreeSet<String>(); Collection<List<ResourceFolder>> folderList = mFolderMap.values(); for (List<ResourceFolder> folderSubList : folderList) { for (ResourceFolder folder : folderSubList) { FolderConfiguration config = folder.getConfiguration(); // get the language LocaleQualifier locale = config.getLocaleQualifier(); if (locale != null && currentLanguage.equals(locale.getLanguage()) && locale.getRegion() != null) { set.add(locale.getRegion()); } } } return set; }
Example 6
Source File: LintUtils.java From javaide with GNU General Public License v3.0 | 5 votes |
/** * Returns the locale for the given parent folder. * * @param parent the name of the parent folder * @return null if the locale is not known, or a locale qualifier providing the language * and possibly region */ @Nullable public static LocaleQualifier getLocale(@NonNull String parent) { if (parent.indexOf('-') != -1) { FolderConfiguration config = FolderConfiguration.getConfigForFolder(parent); if (config != null) { return config.getLocaleQualifier(); } } return null; }
Example 7
Source File: AbstractResourceRepository.java From javaide with GNU General Public License v3.0 | 5 votes |
/** * Returns the sorted list of languages used in the resources. */ @NonNull public SortedSet<String> getLanguages() { SortedSet<String> set = new TreeSet<String>(); // As an optimization we could just look for values since that's typically where // the languages are defined -- not on layouts, menus, etc -- especially if there // are no translations for it Set<String> qualifiers = Sets.newHashSet(); synchronized (ITEM_MAP_LOCK) { for (ListMultimap<String, ResourceItem> map : getMap().values()) { for (ResourceItem item : map.values()) { qualifiers.add(item.getQualifiers()); } } } for (String s : qualifiers) { FolderConfiguration configuration = FolderConfiguration.getConfigForQualifierString(s); if (configuration != null) { LocaleQualifier locale = configuration.getLocaleQualifier(); if (locale != null) { set.add(locale.getLanguage()); } } } return set; }
Example 8
Source File: AbstractResourceRepository.java From javaide with GNU General Public License v3.0 | 5 votes |
/** * Returns the sorted list of languages used in the resources. */ @NonNull public SortedSet<LocaleQualifier> getLocales() { SortedSet<LocaleQualifier> set = new TreeSet<LocaleQualifier>(); // As an optimization we could just look for values since that's typically where // the languages are defined -- not on layouts, menus, etc -- especially if there // are no translations for it Set<String> qualifiers = Sets.newHashSet(); synchronized (ITEM_MAP_LOCK) { for (ListMultimap<String, ResourceItem> map : getMap().values()) { for (ResourceItem item : map.values()) { qualifiers.add(item.getQualifiers()); } } } for (String s : qualifiers) { FolderConfiguration configuration = FolderConfiguration.getConfigForQualifierString(s); if (configuration != null) { LocaleQualifier locale = configuration.getLocaleQualifier(); if (locale != null) { set.add(locale); } } } return set; }
Example 9
Source File: AbstractResourceRepository.java From javaide with GNU General Public License v3.0 | 5 votes |
/** * Returns the sorted list of regions used in the resources with the given language. * @param currentLanguage the current language the region must be associated with. */ @NonNull public SortedSet<String> getRegions(@NonNull String currentLanguage) { SortedSet<String> set = new TreeSet<String>(); // As an optimization we could just look for values since that's typically where // the languages are defined -- not on layouts, menus, etc -- especially if there // are no translations for it Set<String> qualifiers = Sets.newHashSet(); synchronized (ITEM_MAP_LOCK) { for (ListMultimap<String, ResourceItem> map : getMap().values()) { for (ResourceItem item : map.values()) { qualifiers.add(item.getQualifiers()); } } } for (String s : qualifiers) { FolderConfiguration configuration = FolderConfiguration.getConfigForQualifierString(s); if (configuration != null) { LocaleQualifier locale = configuration.getLocaleQualifier(); if (locale != null && locale.getRegion() != null && locale.getLanguage().equals(currentLanguage)) { set.add(locale.getRegion()); } } } return set; }
Example 10
Source File: FullyQualifiedName.java From bazel with Apache License 2.0 | 5 votes |
private static Qualifiers getQualifiers(Iterable<String> dirNameAndQualifiers) { PeekingIterator<String> rawQualifiers = Iterators.peekingIterator(dirNameAndQualifiers.iterator()); // Remove directory name final ResourceFolderType folderType = ResourceFolderType.getTypeByName(rawQualifiers.next()); // If there is no folder type, there are no qualifiers to parse. if (folderType == null) { return EMPTY_QUALIFIERS; } List<String> handledQualifiers = new ArrayList<>(); // Do some substitution of language/region qualifiers. while (rawQualifiers.hasNext()) { handledQualifiers.add(rawQualifiers.next()); } // Create a configuration FolderConfiguration config = FolderConfiguration.getConfigFromQualifiers(handledQualifiers); // FolderConfiguration returns an unhelpful null when it considers the qualifiers to be // invalid. if (config == null) { throw new IllegalArgumentException( String.format(INVALID_QUALIFIERS, DASH_JOINER.join(dirNameAndQualifiers))); } config.normalize(); ImmutableList.Builder<String> builder = ImmutableList.<String>builder(); // index 3 is past the country code, network code, and locale indices. for (int i = 0; i < FolderConfiguration.getQualifierCount(); ++i) { addIfNotNull(config.getQualifier(i), builder); } return new Qualifiers(folderType, builder.build(), config.getLocaleQualifier() == null); }