[longomatch] Add a gettext helper to list available languages
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Add a gettext helper to list available languages
- Date: Tue, 25 Jun 2013 12:45:44 +0000 (UTC)
commit 5f48af2d36aead621f71154cf44b9926b92c3fb3
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Tue Jun 25 14:39:40 2013 +0200
Add a gettext helper to list available languages
LongoMatch.Core/Common/Gettext.cs | 56 +++++++++++++++++++++++++++++++++++
LongoMatch.Core/LongoMatch.Core.mdp | 1 +
LongoMatch.Core/Makefile.am | 1 +
3 files changed, 58 insertions(+), 0 deletions(-)
---
diff --git a/LongoMatch.Core/Common/Gettext.cs b/LongoMatch.Core/Common/Gettext.cs
new file mode 100644
index 0000000..30c76ca
--- /dev/null
+++ b/LongoMatch.Core/Common/Gettext.cs
@@ -0,0 +1,56 @@
+//
+// Copyright (C) 2013 Andoni Morales Alastruey
+//
+// 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+using System;
+using System.IO;
+using System.Collections.Generic;
+using System.Globalization;
+
+namespace LongoMatch.Common
+{
+ public class Gettext
+ {
+ public static List<CultureInfo> Languages {
+ get {
+ List<CultureInfo> langs;
+ string filename, localesDir;
+
+ langs = new List<CultureInfo>();
+ filename = String.Format ("{0}.mo", Constants.SOFTWARE_NAME.ToLower());
+ localesDir = Config.RelativeToPrefix("share/locale");
+
+ langs.Add (new CultureInfo ("en"));
+
+ if (!Directory.Exists (localesDir))
+ return langs;
+
+ foreach (string dirpath in Directory.EnumerateDirectories (localesDir)) {
+ if (File.Exists (Path.Combine (dirpath, "LC_MESSAGES", filename))) {
+ try {
+ string localeName =
Path.GetFileName(dirpath).Replace("_", "-");
+ langs.Add(new CultureInfo (localeName));
+ } catch (Exception ex) {
+ Log.Exception (ex);
+ }
+ }
+ }
+ return langs;
+ }
+ }
+ }
+}
+
diff --git a/LongoMatch.Core/LongoMatch.Core.mdp b/LongoMatch.Core/LongoMatch.Core.mdp
index e0a28c0..19bca28 100644
--- a/LongoMatch.Core/LongoMatch.Core.mdp
+++ b/LongoMatch.Core/LongoMatch.Core.mdp
@@ -105,6 +105,7 @@
<File subtype="Code" buildaction="Compile" name="Common/SysInfo.cs" />
<File subtype="Code" buildaction="Compile" name="Interfaces/IDataBaseManager.cs" />
<File subtype="Code" buildaction="Compile" name="Common/EncodingQuality.cs" />
+ <File subtype="Code" buildaction="Compile" name="Common/Gettext.cs" />
</Contents>
<References>
<ProjectReference type="Gac" localcopy="True" refto="System, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089" />
diff --git a/LongoMatch.Core/Makefile.am b/LongoMatch.Core/Makefile.am
index 1944f50..d1577e2 100644
--- a/LongoMatch.Core/Makefile.am
+++ b/LongoMatch.Core/Makefile.am
@@ -14,6 +14,7 @@ SOURCES = \
Common/EncodingProfiles.cs \
Common/EncodingSettings.cs \
Common/Enums.cs \
+ Common/Gettext.cs \
Common/Image.cs \
Common/Job.cs \
Common/Log.cs \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]