[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Arabic (transliterated) Input Method for Gtk+ was Re: Arabize 0.1



On Rab, 2004-03-17 at 03:37, Behdad Esfahbod wrote:
> This thing should be implemented as an Input Method with lots of
> frameworks are already in place...

Well, I can't sleep tonight so I tried to make my self sleepy
by traversing the gtk+ source code from garnome. Found the 
modules/input subdir and hacked the Makefile and copied
the modules of Cyrillic Input Method. After had figured out
that the key sequences must be sorted in latin order for about an hour,
then this is it, "The Arabic (Transliterated) Input Method for Gtk+"
(tm). Alhamdulillah.

To Owen: Could you please review this patch and commit to gnome cvs?
(btw I have the gnome cvs account, I will commit it my self if you don't
mind.)

To Arabeyes folks: Could you guys review the key sequence I proposed in
the patch. I'm not an Arab, and I don't know how you guys write
transliterated Arabic. My approach is to follow some transliteration
rule in Indonesian and grab some from Amr Diab song lyrics *-)
eg. We (Indonesian) use 'h' for 'ح' (ARABIC LETTER HAH), but I see in
the lyrics, the writer uses '7'. 

The key sequence is not yet fully completed to cover all ARABIC section
in Unicode because I don't know what is the transliteration (eg. ARABIC
LETTER TEH WITH RING, ARABIC LETTER BEEH, etc).

Hope this is useful for all of us (especially the GNOME users here,
hello Arafat *-) and thanks to Ahmad Kamal and Behdad Esfahbod for the
inspiration.

If you don't find this to be useful, maybe you can fork it to make a
(true) Arabic Input Method which maps US keyboard to Arabic.
-- 
Mohammad DAMT <mdamt at bisnisweb dot com>
http://www.bisnisweb.net ASP.Net Linux web hosting
--- Makefile.am-orig	2004-03-18 01:01:02.000000000 +0700
+++ Makefile.am	2004-03-18 01:02:02.000000000 +0700
@@ -71,6 +71,10 @@
 im_inuktitut_la_SOURCES = iminuktitut.c
 im_inuktitut_la_LIBADD = $(LDADDS)
 
+im_arabic_translit_la_LDFLAGS = -rpath $(moduledir) -avoid-version -module $(no_undefined)
+im_arabic_translit_la_SOURCES = imarabic-translit.c
+im_arabic_translit_la_LIBADD = $(LDADDS)
+
 im_ipa_la_LDFLAGS = -rpath $(moduledir) -avoid-version -module $(no_undefined)
 im_ipa_la_SOURCES = imipa.c
 im_ipa_la_LIBADD = $(LDADDS)
@@ -116,6 +120,7 @@
 	im-cyrillic-translit.la			\
 	im-hangul.la				\
 	im-inuktitut.la				\
+	im-arabic-translit.la				\
 	im-ipa.la				\
 	im-thai-broken.la			\
 	im-ti-er.la				\
--- imarabic-translit.c	2004-03-18 01:03:44.545813000 +0700
+++ imarabic-translit.c	2004-03-18 00:53:23.000000000 +0700
@@ -0,0 +1,190 @@
+/* GTK - The GIMP Toolkit
+ * Copyright (C) 2000 Red Hat Software
+ * Copyright (C) 2000 SuSE Linux Ltd
+ * Copyright (C) 2004 Arabeyes.org
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Original author: Owen Taylor <otaylor at redhat dot com>
+ * 
+ * Modified for Arabic - Mohammad DAMT <mdamt at mdamt dot net>
+ *
+ */
+
+#include <string.h>
+
+#include <gdk/gdkkeysyms.h>
+
+#include "gtk/gtkintl.h"
+#include "gtk/gtkimcontextsimple.h"
+#include "gtk/gtkimmodule.h"
+
+GType type_arabic_translit_translit = 0;
+
+static void arabic_translit_class_init (GtkIMContextSimpleClass *class);
+static void arabic_translit_init (GtkIMContextSimple *im_context);
+
+static void
+arabic_translit_register_type (GTypeModule *module)
+{
+  static const GTypeInfo object_info =
+  {
+    sizeof (GtkIMContextSimpleClass),
+    (GBaseInitFunc) NULL,
+    (GBaseFinalizeFunc) NULL,
+    (GClassInitFunc) arabic_translit_class_init,
+    NULL,           /* class_finalize */
+    NULL,           /* class_data */
+    sizeof (GtkIMContextSimple),
+    0,
+    (GInstanceInitFunc) arabic_translit_init,
+  };
+
+  type_arabic_translit_translit = 
+    g_type_module_register_type (module,
+				 GTK_TYPE_IM_CONTEXT_SIMPLE,
+				 "GtkIMContextArabicTranslit",
+				 &object_info, 0);
+}
+
+static guint16 arabic_translit_compose_seqs[] = {
+
+	GDK_percent,	0,	0,	0,	0,	0x066A, /* ARABIC PERCENT */
+	GDK_asterisk,	0,	0,	0,	0,	0x066D, /* ARABIC FIVE POINTED STARS */
+	GDK_comma,	0,	0,	0,	0,	0x060C, /* ARABIC COMMA */
+	GDK_period,	0,	0,	0,	0,	0x066B, /* ARABIC DECIMAL SEPARATOR */
+	GDK_period,	GDK_apostrophe, 0,	0,	0,	0x066C, /* ARABIC THOUSANDS SEPARATOR */
+
+	GDK_slash, GDK_apostrophe,	0,	0,	0,	0x0652, /* ARABIC SUKUN */
+	GDK_slash, GDK_slash,	0,	0,	0,	0x02F, /* SLASH */
+	GDK_slash, GDK_0,	0,	0,	0,	0x0660, /* ARABIC-INDIC DIGIT ZERO */
+	GDK_slash, GDK_1,	0,	0,	0,	0x0661, /* ARABIC-INDIC DIGIT ONE */
+	GDK_slash, GDK_2,	0,	0,	0,	0x0662, /* ARABIC-INDIC DIGIT TWO */
+	GDK_slash, GDK_3,	0,	0,	0,	0x0663, /* ARABIC-INDIC DIGIT THREE */
+	GDK_slash, GDK_4,	0,	0,	0,	0x0664, /* ARABIC-INDIC DIGIT FOUR */
+	GDK_slash, GDK_5,	0,	0,	0,	0x0665, /* ARABIC-INDIC DIGIT FIVE */
+	GDK_slash, GDK_6,	0,	0,	0,	0x0666, /* ARABIC-INDIC DIGIT SIX */
+	GDK_slash, GDK_7,	0,	0,	0,	0x0667, /* ARABIC-INDIC DIGIT SEVEN */
+	GDK_slash, GDK_8,	0,	0,	0,	0x0668, /* ARABIC-INDIC DIGIT EIGHT */
+	GDK_slash, GDK_9,	0,	0,	0,	0x0669, /* ARABIC-INDIC DIGIT NINE */
+
+	GDK_2,	0,	0,	0,	0,	0x0639, /* ARABIC LETTER AIN */
+	GDK_2,	GDK_apostrophe,	0,	0,	0,	0x0655, /* ARABIC LETTER HAMZA BELOW */
+	GDK_2,	GDK_slash,	0,	0,	0,	0x0654, /* ARABIC LETTER HAMZA ABOVE */
+	GDK_3,	0,	0,	0,	0,	0x0651, /* ARABIC SHADDA */
+	GDK_7, 0,	0,	0,	0,	0x062D, /* ARABIC LETTER HAH */
+	GDK_7, GDK_apostrophe,	0,	0,	0,	0x062E, /* ARABIC LETTER KHAH */
+
+	GDK_semicolon,	0,	0,	0,	0,	0x061B, /* ARABIC SEMICOLON */
+	GDK_question, 0,	0,	0,	0,	0x061F, /* ARABIC QUESTION MARK */
+	GDK_H, 0,	0,	0,	0,	0x0629, /* ARABIC LETTER TEH MARBUTA */
+
+	GDK_underscore, 0,	0,	0,	0,	0x0640, /* ARABIC LETTER TATWEEL */	
+
+	GDK_a, 0,   0,  0,  0,  0x0627, /* ARABIC LETTER ALEF */
+	GDK_a,	GDK_apostrophe,	0,	0,	0,	0x064E, /* ARABIC FATHA */
+	GDK_a,	GDK_apostrophe,	GDK_n,	0,	0,	0x064B, /* ARABIC FATHATAN */
+	
+	GDK_a, GDK_slash,	GDK_slash,	0,	0,	0x0622, /* ARABIC LETTER ALEF WITH MADDA ABOVE */
+	GDK_a, GDK_slash,	GDK_2,	0,	0,	0x0623, /* ARABIC LETTER ALEF WITH HAMZA ABOVE */
+	GDK_a, GDK_slash,	GDK_h,	0,	0,	0x0625, /* ARABIC LETTER ALEF WITH MADDA BELOW */
+	GDK_b, 0,   0,	0,  0,  0x0628, /* ARABIC LETTER BEH */
+	GDK_c, 0,	0,	0,	0,	0x062B, /* ARABIC LETTER THEH */
+	GDK_d, 0,	0,	0,	0,	0x062F, /* ARABIC LETTER DAL */
+	GDK_d, GDK_apostrophe,	0,	0,	0,	0x0630, /* ARABIC LETTER THAL */
+	GDK_d, GDK_slash,	0,	0,	0,	0x0636, /* ARABIC LETTER DAD */
+	GDK_f, 0,	0,	0,	0,	0x0641, /* ARABIC LETTER FEH */
+	GDK_g, GDK_apostrophe,	0,	0,	0,	0x063A, /* ARABIC LETTER GHAIN */
+	GDK_h, 0,	0,	0,	0,	0x0647, /* ARABIC LETTER HEH */
+	GDK_i,	0, 0,	0,	0,	0x0650, /* ARABIC KASRA */
+	GDK_i,	GDK_n,	0,	0,	0,	0x064D, /* ARABIC KASRATAN */	
+	GDK_j, 0,	0,	0,	0,	0x062C, /* ARABIC LETTER JEEM */
+	GDK_k, 0,	0,	0,	0,	0x0643, /* ARABIC LETTER KAF */
+	GDK_l, 0,	0,	0,	0,	0x0644, /* ARABIC LETTER LAM */
+	GDK_m, 0,	0,	0,	0,	0x0645, /* ARABIC LETTER MEEM */
+	GDK_n, 0,	0,	0,	0,	0x0646, /* ARABIC LETTER NOON */
+	GDK_q, 0,	0,	0,	0,	0x0642, /* ARABIC LETTER QAF */
+	GDK_r, 0,	0,	0,	0,	0x0631, /* ARABIC LETTER REH */
+	GDK_s, 0,	0,	0,	0,	0x0633, /* ARABIC LETTER SEEN */
+	GDK_s, GDK_apostrophe,	0,	0,	0,	0x0634, /* ARABIC LETTER SHEEN */
+	GDK_s, GDK_slash,	0,	0,	0,	0x0635, /* ARABIC LETTER SAD */
+	GDK_t, 0,	0,	0,	0,	0x062A, /* ARABIC LETTER TEH */
+	GDK_t, GDK_apostrophe,	0,	0,	0,	0x0637, /* ARABIC LETTER TAH */
+	GDK_u,	0, 0,	0,	0,	0x064F, /* ARABIC DAMMA */
+	GDK_u,	GDK_n,	0,	0,	0,	0x064C, /* ARABIC DAMMATAN */
+	GDK_w, 0,	0,	0,	0,	0x0648, /* ARABIC LETTER WAW */
+	GDK_w, GDK_2,	0,	0,	0,	0x0626, /* ARABIC LETTER WAW WITH HAMZA ABOVE */
+	GDK_y, 0,	0,	0,	0,	0x064A, /* ARABIC LETTER YEH */
+	GDK_y, GDK_slash,	0,	0,	0,	0x0649, /* ARABIC LETTER LETTER ALEF MAKSURA */
+	GDK_y, GDK_slash,	GDK_2,	0,	0,	0x0626, /* ARABIC LETTER YEH WITH HAMZA ABOVE */
+	GDK_z, 0,	0,	0,	0,	0x0632, /* ARABIC LETTER ZAIN */
+	GDK_z, GDK_apostrophe,	0,	0,	0,	0x0638, /* ARABIC LETTER ZAH */
+	GDK_asciitilde,	0,	0,	0,	0,	0x0653, /* ARABIC MADDAH ABOVE */
+};
+
+static void
+arabic_translit_class_init (GtkIMContextSimpleClass *class)
+{
+}
+
+static void
+arabic_translit_init (GtkIMContextSimple *im_context)
+{
+  gtk_im_context_simple_add_table (im_context,
+				   arabic_translit_compose_seqs,
+				   4,
+				   G_N_ELEMENTS (arabic_translit_compose_seqs) / (4 + 2));
+}
+
+static const GtkIMContextInfo arabic_translit_info = { 
+  "arabic_translit",		   /* ID */
+  N_("Arabic (Transliterated)"),         /* Human readable name */
+  GETTEXT_PACKAGE,	   /* Translation domain */
+  GTK_LOCALEDIR,	   /* Dir for bindtextdomain (not strictly needed for "gtk+") */
+  "ar"			   /* Languages for which this module is the default */
+};
+
+static const GtkIMContextInfo *info_list[] = {
+  &arabic_translit_info
+};
+
+void
+im_module_init (GTypeModule *module)
+{
+  arabic_translit_register_type (module);
+}
+
+void 
+im_module_exit (void)
+{
+}
+
+void 
+im_module_list (const GtkIMContextInfo ***contexts,
+		int                      *n_contexts)
+{
+  *contexts = info_list;
+  *n_contexts = G_N_ELEMENTS (info_list);
+}
+
+GtkIMContext *
+im_module_create (const gchar *context_id)
+{
+  if (strcmp (context_id, "arabic_translit") == 0)
+    return GTK_IM_CONTEXT (g_object_new (type_arabic_translit_translit, NULL));
+  else
+    return NULL;
+}

Attachment: arabic-translit.png
Description: PNG image