|
What this is
Other links
The source code/******************************************************************************* * Copyright (c) 2008 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation * Benjamin Cabe <benjamin.cabe@anyware-tech.com> - bug 215232 *******************************************************************************/ package org.eclipse.pde.internal.ui.util; import java.util.Locale; import java.util.StringTokenizer; public class LocaleUtil { public static String[] getLocales() { Locale[] locales = Locale.getAvailableLocales(); String[] result = new String[locales.length]; for (int i = 0; i < locales.length; i++) { Locale locale = locales[i]; StringBuffer buffer = new StringBuffer(); buffer.append(locale.toString()); buffer.append(" - "); //$NON-NLS-1$ buffer.append(locale.getDisplayName()); result[i] = buffer.toString(); } return result; } public static String expandLocaleName(String name) { String language = ""; //$NON-NLS-1$ String country = ""; //$NON-NLS-1$ String variant = ""; //$NON-NLS-1$ StringTokenizer tokenizer = new StringTokenizer(name, "_"); //$NON-NLS-1$ if (tokenizer.hasMoreTokens()) language = tokenizer.nextToken(); if (tokenizer.hasMoreTokens()) country = tokenizer.nextToken(); if (tokenizer.hasMoreTokens()) variant = tokenizer.nextToken(); Locale locale = new Locale(language, country, variant); return locale.toString() + " - " + locale.getDisplayName(); //$NON-NLS-1$ } } |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.