[gnome-shell/wip/carlosg/osk-cldr: 19/45] data: Add README and supporting script to update keyboard layouts from CLDR



commit 9cadd415e280fe5d0d717cae553cecb6db07cdf4
Author: Carlos Garnacho <carlosg gnome org>
Date:   Fri Nov 10 15:26:48 2017 +0100

    data: Add README and supporting script to update keyboard layouts from CLDR
    
    The README describes the steps in detail, but most of it is abstracted away
    by the update-osk-layouts.sh script.

 .gitignore                 |  1 +
 data/README.osk-layouts    | 33 +++++++++++++++++++++++++++++++
 data/update-osk-layouts.sh | 48 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 82 insertions(+)
---
diff --git a/.gitignore b/.gitignore
index 342a545c3..451a5ac46 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,6 +8,7 @@ ChangeLog
 INSTALL
 aclocal.m4
 autom4te.cache
+data/.osk-layout-workbench
 data/org.gnome.Shell.desktop
 data/org.gnome.Shell.desktop.in
 data/gnome-shell-extension-prefs.desktop
diff --git a/data/README.osk-layouts b/data/README.osk-layouts
new file mode 100644
index 000000000..e9e668f34
--- /dev/null
+++ b/data/README.osk-layouts
@@ -0,0 +1,33 @@
+Gnome-shell OSK layouts are extracted from CLDR layout definitions:
+https://www.unicode.org/cldr/charts/latest/keyboards/layouts/index.html
+
+Updating these involves several steps:
+
+1) Downloading and unzipping the tarball found at:
+   http://www.unicode.org/Public/cldr/latest/keyboards.zip
+
+   This file contains XML files describing the keyboard layouts.
+
+2) Cloning the cldr2json script at:
+   git://repo.or.cz/cldr2json.git
+
+   It will be used to convert the XML files into JSON that can be
+   directly consumed by gnome-shell.
+
+3) Running the script to produce the files:
+   ./cldr2json <input-directory> <output-directory>
+
+   We shall usually use the "android" folder, since that's most
+   complete, and similar to our UI and target sizes. And the target
+   directory must be data/osk-layouts in this repository.
+
+4) Modify gnome-shell-osk-layouts.gresource.xml to include the files
+
+5) Do git add on the updated/new files, and git commit.
+
+
+Or alternatively:
+
+1) Run update-osk-layouts.sh
+
+2) Do git add and git commit
diff --git a/data/update-osk-layouts.sh b/data/update-osk-layouts.sh
new file mode 100755
index 000000000..bb452c3e2
--- /dev/null
+++ b/data/update-osk-layouts.sh
@@ -0,0 +1,48 @@
+#!/bin/env bash
+
+CLDR_LAYOUTS_TARBALL="http://www.unicode.org/Public/cldr/latest/keyboards.zip";
+CLDR2JSON_GIT="git://repo.or.cz/cldr2json.git"
+
+WORKDIR=".osk-layout-workbench"
+CLDR2JSON="$WORKDIR/cldr2json/cldr2json.py"
+SRCDIR="$WORKDIR/keyboards/android"
+DESTDIR="osk-layouts"
+GRESOURCE_FILE="gnome-shell-osk-layouts.gresource.xml"
+TMP_GRESOURCE_FILE=".$GRESOURCE_FILE.tmp"
+
+cd `dirname $0`
+
+# Ensure work/dest dirs
+rm -rf $WORKDIR
+mkdir -p $WORKDIR
+mkdir -p "osk-layouts"
+
+# Download stuff on the work dir
+pushd $WORKDIR
+gio copy $CLDR_LAYOUTS_TARBALL .
+git clone $CLDR2JSON_GIT
+unzip keyboards.zip
+popd
+
+# Transform to JSON files
+$CLDR2JSON $SRCDIR $DESTDIR
+
+# Generate new gresources xml file
+cat >$TMP_GRESOURCE_FILE <<EOF
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/org/gnome/shell/osk-layouts">
+EOF
+
+for f in $DESTDIR/*.json
+do
+    echo "    <file>$(basename $f)</file>" >>$TMP_GRESOURCE_FILE
+done
+
+cat >>$TMP_GRESOURCE_FILE <<EOF
+  </gresource>
+</gresources>
+EOF
+
+# Rewrite old gresources xml
+mv $TMP_GRESOURCE_FILE $GRESOURCE_FILE


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