// clsLocalization.cs
// Copyright (C) 2008 Karel Jordaan karel_jordaan@yahoo.com.au
// 
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

using System;
using System.Globalization;
using System.Threading;
using GUIControlLogic.Error;

namespace GUIControlLogic
{
    /// <summary>
    /// Class to handle Localization.
    /// </summary>
    /// <remarks>None</remarks>
    public class clsLocalization : clsGlobalErr, IDisposable
    {
        #region Functions

        /// <summary>
        /// Dispose of the class.
        /// </summary>
        /// <remarks>None</remarks>
        public void Dispose()
        {
            // TODO:  Add clsLocalization.Dispose implementation
        }

        /// <summary>Gets the friendly name for language codes</summary>
        /// <returns>Returns a string array of language names </returns>
        /// <param name="str">An array of language codes </param> 
        /// <remarks>None</remarks>
        public string[] GetNameFromCode(string[] str)
        {
            string[] names = new string[str.Length];

            try
            {
                str.CopyTo(names, 0);
                //Ret the  friendly name for culture given the code
                for (int i = 0; i <= str.Length - 1; i++)
                {
                    CultureInfo ci = new CultureInfo(str[i]);
                    names[i] = ci.DisplayName;
                }
                return names;
            }

            catch (Exception  ex)
            {
                 new clsExeption(ex);
                ErrByte = 1;
                return names;
            }
        }

        /// <summary>Sets the current Thread to a specific culture</summary>
        /// <param name="str">A string formatted as language code</param> 
        /// <remarks>None</remarks>
        public void SetCulture(string str)
        {
            try
            {
                CultureInfo ci = new CultureInfo(str);
                Thread.CurrentThread.CurrentUICulture = ci;
            }
            catch (Exception  ex)
            {
                 new clsExeption(ex);
                ErrByte = 1;
            }
        }

        #endregion
    }
}