Displaying the available locales in english | Unix Linux Forums | Red Hat

  Go Back    


Red Hat Red Hat is the world's leading open source technology solutions provider with offerings including Red Hat Enterprise Linux (RHEL), Fedora, open source applications, security and systems management, virtualization, and Services Oriented Architecture (SOA) solutions.

Displaying the available locales in english

Red Hat


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 05-16-2008
eamani_sun eamani_sun is offline
Registered User
 
Join Date: May 2008
Last Activity: 14 October 2008, 12:57 PM EDT
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Displaying the available locales in english

Hi,

I am developing a program that would ask the user to set the locale.

For that, I need to display them to user in plain english.

like

English(US)
English (Uk)

depending on the user selection I need to set the locale.

Is there a command in redhat linux that would display locales in more friendly mamner rather than like this "en-US.UTF-8"

Thanks,
sunny.
Sponsored Links
    #2  
Old 07-27-2008
p50p100 p50p100 is offline
Registered User
 
Join Date: Mar 2008
Last Activity: 15 April 2013, 8:19 AM EDT
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by eamani_sun View Post
Hi,

I am developing a program that would ask the user to set the locale.

For that, I need to display them to user in plain english.

like

English(US)
English (Uk)

depending on the user selection I need to set the locale.

Is there a command in redhat linux that would display locales in more friendly mamner rather than like this "en-US.UTF-8"

Thanks,
sunny.

Code:
#!/bin/bash

function dump()
{
	export na_pre
	export na_pos
	export na_len
locale -a | while read na
do
	na_len=${#na}
	#until "_"
	na_pre=${na/_*//}
	na_pre=${#na_pre}
	#before "."
	na_pos=${na/?.*//}
	na_pos=${#na_pos}
	if (( na_len == na_pre || ne_len == na_pos ))
	then	#no include "_", "."
		continue
	fi

	#get length
	((na_pos = na_pos - na_pre))

	#(LANGUAGE NAME)=>L1 , (COUNTRY_NAME)=>L2
	LANG="$na" GET_LANGNAME="L1=`LANG=$LANG locale language` L2=${LANG:$na_pre:$na_pos} L3=${na/.*/}" && export $GET_LANGNAME
	echo $L1\($L2\)\/$L3
done
}

dump  | uniq | while read sel
do
	echo "$sel"
done

If I do it, I'll use "locale language". code above is example.

Last edited by p50p100; 07-27-2008 at 06:40 PM..
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Detecting browser locales/languages and generating output uunniixx Web Programming 1 02-18-2011 08:30 PM
HPUX 10.20 - Warning! One or more of your selected locales are not available. jmdzied HP-UX 1 10-05-2010 05:13 AM
formatting date for different locales Aeon UNIX for Dummies Questions & Answers 2 08-23-2007 12:39 AM
Locales in AIX voorkey AIX 0 06-08-2006 01:08 PM
Locales - Solaris 8 finster UNIX for Dummies Questions & Answers 2 07-26-2003 12:24 PM



All times are GMT -4. The time now is 03:28 AM.