\documentclass[xcolor=dvipsnames]{beamer}
%\usetheme{Copenhagen} %biase je,cun,front title rounded,agenda round
%\usetheme{Luebeck}
%\usetheme{JuanLesPins} %biase, round agenda, shadowed title
%\usetheme{Rochester}%ikutkan ni yg paling ngam,tapi nak kena buang frametitle,tak scalable
%\usetheme{Darmstadt}
%\usetheme{Warsaw}
%\usetheme{Berlin} % I like!!! although front title takde shadow, tapi leh tweak
%\usetheme{Frankfurt} % biasa, shadowed title, round agenda
%\usetheme{Antibes}% agenda gune petak, tapi tree theme tak jalan
%\usetheme{Ilmenau}
%\usetheme{Bergen} %tak best,petak, and agenda beso sangat
%\usetheme{Pittsburgh} %tak best,petak, frametitle belah kanan
%\usetheme{Montpellier} %tak best,petak,agenda xde bullet
%\usetheme{Szeged} %tak best,petak,agenda xde bullet
%\usetheme{Hannover} %agenda blah tepi,x muat
%\usetheme{Bergen} %agenda blah tepi,x muat,beso
%\usetheme{Boadilla} % biase je, shadow title, round bullet for agenda
\usetheme{AnnArbor} % biase je, shadow title, round bullet for agenda
%\usetheme{CambridgeUS} % biase je, shadow title, round bullet for agenda\usecolortheme[named=Brown]URtructure}
%\setbeamercolor{named=OliveGreen}{structure}
%\usecolortheme[named=NavyBlue]{structure}
%\setbeamercolor{named=Yellow}{structure}
\usecolortheme{crane}
\setbeamercolor{frametitle}{fg=black!70!blue}
%\setbeamertemplate{items} [ball] % [square]
%\setbeamertemplate{blocks}[rounded][shadow=true]
\setbeamertemplate{navigation symbols}{}
\useoutertheme{infolines}
\usepackage{graphicx}
\usepackage{listings}
\usepackage{color}
\usepackage{colortbl}
\usepackage{array}
\usepackage{pgf}
\usepackage{arabtex}
%\usetheme{Air}
%\usetheme{Oxygen}
%\setbeamertemplate{background}{\includegraphics[width=\paperwidth,height=\paperheight]{desenho}}
%\usepackage{lucidaso}
%\usepackage{beamerthemesplit}
\usepackage[bars]{beamerthemetree}
%this is for my arrow
\usepackage{times}
\usepackage{tikz}
\usepackage{amsmath}
\usepackage{verbatim}
\usetikzlibrary{arrows,shapes}
\setbeamertemplate{sections/subsections in toc}[square]
\setbeamertemplate{items}[square]
%\usepackage{epstopdf}
\begin{document}
%\setbeamertemplate{itemize item}{\includegraphics[height=1em]{./kde-icon}}
\setbeamertemplate{itemize item}{\includegraphics[height=1em]{/usr/share/pixmaps/gnome-debian.png}}
\lstset{basicstyle=\tiny,frame=shadowbox, rulesepcolor=\color{black}}
\title[foss.my 2009]{Software Internationalization (i18n) \emph{with GNU gettext}}
\author [Muhammad Najmi]{Muhammad Najmi Ahmad Zabidi}
%pg 1
\section*{Welcome}
\begin{frame}
\title{Software Internationalization (i18n) with \emph{GNU gettext}}
\author {Muhammad Najmi Ahmad Zabidi}
\date{25th October 2009}
\institute {Department of Computer Science\\
KICT, International Islamic University Malaysia,\\
MALAYSIA}
\titlepage
\begin{center} \texttt{najmi@kict.iiu.edu.my}\\
\footnotesize{\textrm{Created with \LaTeX{} \\}}
\end{center}
\end{frame}
%pg2
\section*{Agenda}
%\begin{frame}[allowframebreaks]
\transboxin
%\frametitle{Agenda}
%\setcounter{tocdepth}{1}
%\tableofcontents[currentsections]
%\end{frame}
%print for each subsec
%\begin{comment}
%\AtBeginSubsection[]
\AtBeginSection[]
{
\begin{frame}[shrink]%<beamer>
\frametitle{Agenda}
\setcounter{tocdepth}{1}
% \tableofcontents[currentsection,currentsubsection]
\tableofcontents[currentsection]
\end{frame}
}
%\end{comment}
%pg3 to pg6
\section{About}
\begin{frame}[shrink]{About the speaker}
\transdissolve
\begin{itemize}
\item<1-> KDE Subversion committer and original translator to ms\mbox{\_}MY
\pause
\item<2-> Translation CVS committer for Tuxpaint project
\pause
\item<3-> Occasionally sending translation for GNU ms\mbox{\_}MY, (Munsyi Project), lead by Sharuzzaman
\end{itemize}
\pause
\onslide <1-> \pgfputat{\pgfxy(5.5,-3.5)}{\pgfbox[top,right]{\includegraphics[scale=0.2]{./kde.png}}}
\onslide <2->\pgfputat{\pgfxy(10.25,-3.5)}{\pgfbox[top,right]{\includegraphics[scale=0.2]{./tux.png}}}
\onslide <3->\pgfputat{\pgfxy(0.5,-3.5)}{\pgfbox[top,right]{\includegraphics[scale=0.17]{./gnu.png}}}
\end{frame}
\section{Internationalization}
\begin{frame}
\frametitle{Internationalization}
\transglitter
What actually internationalization is:
\begin{itemize}
\item Software going global
\pause
\item Software package getting ``world'' acceptance, thus people willing to localize it
\pause
\item Needs i18n support first!
\end{itemize}
\end{frame}
\subsection{Localization vs Internationalization}
\begin{frame}{The differences\ldots}
\begin{columns}<1->
\column{0.35\textwidth}
\begin{alertblock}{ Localization}
\begin{itemize}
\item Done by translator
\item It can be by the user/Developer
\item Submit to package maintainer
\item Get credit
\end{itemize}
\end{alertblock}
\pause
\column{0.35\textwidth}
\begin{exampleblock}{Internationalization}<2->
\begin{itemize}
\item Developer
\item Prepare package
\item Merge package
\item Update package
\item Announce new package
\item Give proper credit
\end{itemize}
\end{exampleblock}
\end{columns}
\end{frame}
%pg7
\section{gettext}
\begin{frame}
\frametitle{gettext}
\begin{exampleblock}{gettext's features}
\begin{itemize}
\item Part of GNU packages
\item Enables internationalization of software
\item Enables the creation of Portable Object (PO) file
\end{itemize}
\end{exampleblock}
\begin{center}
\emph{Portable Object?}
\end{center}
\end{frame}
\subsection{Features}
\begin{frame}\frametitle{Gettext features}
\begin{block}{Why gettext?}
\begin{itemize}
\item Supports major characters encoding \ldots
\item UTF-8 for an example
\item KDE,Gnome, Squirrelmail use it
\item Relatively to update and maintain
\end{itemize}
\end{block}
\end{frame}
\section{Task of developer/translator}
\begin{frame}
\frametitle{What developers and translators should do?}
\includegraphics[scale=0.26]{process.png}
\end{frame}
\section{Flow of the translation process}
\begin{frame}
\frametitle{Flow of Translation}
\begin{center}
\includegraphics[scale=0.6]{po-mo-flow.png}
\end{center}
\end{frame}
\subsection{PO file}
\begin{frame}
\frametitle{Portable Object (PO) files}
\begin{block}{PO file's features}
\begin{itemize}
\item It's a raw, untranslated file
\item Created automatically using gettext package
\item Ready to be translated
\end{itemize}
\end{block}
\end{frame}
\subsection{MO file}
\begin{frame}
\frametitle{Machine Object (MO) files}
\begin{alertblock}{MO file's features}
\begin{itemize}
\item Compiled file, derived from PO
\item It's a binary, thus \emph{machine readable}
\end{itemize}
\end{alertblock}
\end{frame}
\subsection{Location of MO file}
\begin{frame}[fragile]{Default \mbox{\&} customized location}
\begin{itemize}
\item By default Linux refers to
\begin{verbatim}
/usr/share/locale
\end{verbatim}
\item Customized directory
\begin{verbatim}
najmi@notre-dame:/var/www$ tree ms
ms
`-- LC_MESSAGES
|-- greetings.mo
|-- index.mo
`-- messages.mo
\end{verbatim}
\end{itemize}
\end{frame}
\subsection{Creating MO file}
\begin{frame}{Generating Machine Object file}
\begin{block}{How?}
\begin{itemize}
\item Use msgfmt - message format
\item This will generate default name, message.mo, unless you specify it
\item You can trash it out, given you just want to check the localized stats to \texttt {/dev/null}
\item It can be reverted back, use msgunfmt
\end{itemize}
\end{block}
\end{frame}
\subsection{Locale}
\begin{frame}{Intro to locale}
\begin{block}{Locale}
\begin{itemize}
\item Locale is the local setting of a particular country, race, venue etc
\item For Bahasa Melayu, the assigned locale is ms\mbox{\_}MY, where ms is for Malay, and MY is for Malaysia
\item As for now, since Indonesia is using ``id'' , so sometimes ms is just fine
\item Date sequence, for .eg dd/mm/yyyy is also fall under locale . We also do not have Daylight Saving Time(DST), that is also locale
\end{itemize}
\end{block}
Locale can be simply viewed by typing \texttt{\mbox{\$}locale}
\end{frame}
\subsection{Charset}
\begin{frame}{Some stuffs on chartset}
\begin{exampleblock}{Charset?}
\begin{itemize}
\item Different charset support different language, characters
\item Includes Roman, Arabic, CJK and etc
\begin{itemize}
\item UTF-8, UTF-16 etc
\end{itemize}
\item I don't really know on this stuffs, only know Roman based and Arabic based chars
\end{itemize}
\end{exampleblock}
\end{frame}
\section{Codes}
\subsection{Sample of C++ file}
\begin{frame}[fragile]
\frametitle{How's the \emph{C++} file looks like?}
\lstset{basicstyle=\footnotesize, frame=shadowbox, rulesepcolor=\color{black}}
{\lstinputlisting[language=C++]
{./code/hello.cpp}
}
\end{frame}
\subsection{Sample}
\begin{frame}[fragile]{Executable output}
\begin{verbatim}
$ ./hello
Hello, world!
How are you?
\end{verbatim}
\pause
\begin{verbatim}
$ export LC_ALL=ms_MY.UTF-8
\end{verbatim}
\pause
\begin{verbatim}
$ ./hello
Assalamualaikum, dunia!
Awak apa khabar?
\end{verbatim}
\end{frame}
\subsection{xgettext}
\begin{frame}[fragile]
\begin{exampleblock}{About xgettext}
\begin{itemize}
\item Part of gettext
\item Extracting translatable strings from source code
\end{itemize}
\end{exampleblock}
\begin{verbatim}
xgettext -d lang lang.php
\end{verbatim}
\centering{This will create lang.po, with respect to strings in lang.php}
\end{frame}
\subsection{Sample of the POT file}
\begin{frame}[fragile]
\frametitle{How's the \alert{\emph{raw}} POT file looks like?}
{\lstinputlisting
{./code/hello.pot}
}
\end{frame}
\subsection{Sample of the translated PO file}
\begin{frame}[fragile]
\frametitle{How's the \alert{\emph{translated}} PO file looks like?}
{\lstinputlisting
{./code/hello.po}
}
\end{frame}
\subsection{gettext in Python}
\begin{frame}[fragile]
\lstset{basicstyle=\normalsize, frame=shadowbox, rulesepcolor=\color{black}}
\frametitle {python!}
{\lstinputlisting [language=python]
{./code/piton.py}
}
\end{frame}
\subsection{gettext in Python}
\begin{frame}[fragile]
\frametitle {Traslatable strings from Python file}
{\lstinputlisting[language=python]
{./code/piton.po}
}
\end{frame}
\subsection{gettext in Python}
\begin{frame}[fragile]
\frametitle {Python executable}
\pause
\begin{verbatim}
$ python piton.py
python mudah
semudah ini
\end{verbatim}
\pause
\begin{verbatim}
$ export LC_ALL=C
\end{verbatim}
\pause
\begin{verbatim}
$ python piton.py
python is simple
as simple as this
\end{verbatim}
\end{frame}
\subsection{PHP source code}
\begin{frame}[fragile]
\frametitle{Let's see for PHP}
{\lstinputlisting [language=PHP]
{./code/lang.php}
}
\end{frame}
\subsection{PO file generated from the PHP file\ldots}
\begin{frame}[fragile]
\frametitle{Let's see for PHP}
\begin{itemize}
\item The following is the example of snipped file - without header
\end{itemize}
{\lstinputlisting
{./code/lang.po}
}
\end{frame}
\subsection{Ideal PHP code for i18n}
\begin{frame}[fragile]{Avoid confusing translator}
\begin{itemize}
\item Try to put strings in a minimal line
\item Avoid separation of sentence
\end{itemize}
{\lstinputlisting
{./code/lang2.php}
}
\end{frame}
\subsubsection{The ideal code is \ldots}
\begin{frame}[fragile]{Use ``sprintf''}
\centering{Use the following \ldots}\\
\begin{lstlisting}[language=PHP]
echo sprintf(_(``The settings of %s is working fine''),$language);
\end{lstlisting}
\centering{instead of \ldots}\\
\begin{lstlisting}[language=PHP]
echo _(``The settings of '').$language._(`` is working fine");
\end{lstlisting}
\end{frame}
\subsection{Sample confusing strings}
\begin{frame}[fragile]{Separated into two}
\begin{lstlisting}[language=PHP]
echo _(``The settings of '').$language._(`` is working fine");
\end{lstlisting}
\centering{will generate\ldots}\\
\begin{lstlisting}
#: lang.php:11
msgid ``The settings of ''
msgstr ``
#: lang.php:11
msgid '' is working fine``
msgstr ''``''
\end{lstlisting}
\centering{which separates sentence into two different strings\ldots}\\
\end{frame}
\subsection{The ideal coding}
\begin{frame}[fragile]
\begin{lstlisting}[language=PHP]
echo sprintf(_(``The settings of %s is working fine''),$language);
\end{lstlisting}
\centering{since this will generate\ldots}\\
\begin{lstlisting}
msgid ``The settings of %s is working fine''
msgstr ``
\end{lstlisting}
\end{frame}
\subsection{Plural issues}
\begin{frame}[shrink]{What if we have plural noun\ldots}
\begin{itemize}
\item Plural is when you have different noun for singular and plural
\end{itemize}
\begin{columns}
%\column
\begin{column}{.4\textwidth}
\begin{exampleblock}{Singular}
\begin{itemize}
\item <1-> {\alert{ cat}}
\item <2->{\alert{ boy}}
\item<3->{\alert{ man}}
\end{itemize}
\end{exampleblock}
\begin{block}{Singular-Malay}
\begin{itemize}
\item <4->{\alert{ basikal}}
\item <5->{\alert{ pensil}}
\item <6->{\alert{ komputer}}
\end{itemize}
\end{block}
\end{column}
\begin{column}{.4\textwidth}
\begin{exampleblock}{Plural}
\begin{itemize}
\item <1->{\alert {cats}}
\item <2->{\alert {boys}}
\item <3->{\alert {men}}
\end{itemize}
\end{exampleblock}
\begin{block}{Plural-Malay}
\begin{itemize}
\item <4->{\alert{ basikal-basikal}}
\item <5->{\alert {pensil-pensil}}
\item <6->{\alert {komputer-komputer}}
\end{itemize}
\end{block}
\end{column}
\end{columns}
\end{frame}
\begin{frame}
\centering{However, as far as I know, plural issue in Malay languge is non trivial issue, so for the sake of easiness (perhaps, lazy?) plural = 0}
\end{frame}
%\subsection{Plural issues}
\subsection{Using ngettext in PHP}
\begin{frame}[fragile]{ngettext}
{\lstinputlisting[language=PHP]
{./code/nplural.php}
}
\begin{verbatim}
2 boys are eating
1 cat falls
1 tingkap ditutup
Files are good
\end{verbatim}
\end{frame}
\subsection{Using ngettext in PHP}
\begin{frame}[fragile]
\frametitle{Sample PO}
{\lstinputlisting
{./code/nplural.po}
}
\end{frame}
\section{Tools}
\subsection{Internationalization tools}
\begin{frame}
\frametitle{Internationalization tools}
\begin{itemize}
\item gted (very recent)
\item html2po / po2html
\end{itemize}
\end{frame}
\subsection{Localization tools}
\begin{frame}[shrink]
\frametitle{Localization tools}
\begin{columns}
\begin{column}{0.95\textwidth}
\begin{itemize}
\item POedit
\item Kbabel (now lokalize)
\item VI? Emacs ... the list may infinite up to \emph{n} \mbox{\#} of tools
\item Incoming \ldots wish for PO Live Edit, prototype is webl10n by gandalf
\item Pootle
\end{itemize}
\end{column}
\end{columns}
\pgfputat{\pgfxy(10.5,1.3)}{\pgfbox[top,right]{\includegraphics[scale=0.3]{./lokalize.png}}}
\pgfputat{\pgfxy(10,-3)}{\pgfbox[left,bottom]{\includegraphics[scale=0.3]{./kbabel.png}}}
\end{frame}
\section{Route of PO to MO}
\tikzstyle{every picture}+=[remember picture]
\everymath{\displaystyle}
\begin{frame}
\frametitle{PO to MO journey}
\tikzstyle{na} = [baseline=-.25ex]
\begin{itemize}[<+-| alert@+>]
\item Translate
\tikz[na] \node[coordinate] (n1) {};
\end{itemize}
\begin{equation*}
\tikz[baseline]{
\node[fill=blue!20,anchor=base] (t1)
{$PO\ file$};
} ->
\tikz[baseline]{
\node[fill=red!20, ellipse,anchor=base] (t2)
{$MO\ file$};
} ->
\tikz[baseline]{
\node[fill=green!20,anchor=base] (t3)
{$Working\ Interface$};
}
\end{equation*}
\begin{itemize}[<+-| alert@+>]
\item Compile
\tikz[na]\node [coordinate] (n2) {};
\item Invoke
\tikz[na]\node [coordinate] (n3) {};
\end{itemize}
\begin{tikzpicture}[overlay]
\path[->]<1-> (n1) edge [bend left] (t1);
\path[->]<2-> (n2) edge [out=0, in=-90] (t2);
\path[->]<3-> (n3) edge [out=0, in=-90] (t3);
\end{tikzpicture}
\end{frame}
\section{Issues with package generated by gettext}
\begin{frame}[shrink]{Issues}
\begin{alertblock}{What are the issues?}
\begin{itemize}
\item Software may become bloated
\pause
\item So, the user may not install \emph{everything} in the first place!
\pause
\item Mozilla has its own way\ldots{
\begin{itemize}
\item I saw moz2po and po2moz \ldots a good news, perhaps?
\item Bug filed \mbox{\#}501988 seems a good news
\end{itemize}
}
\pause
\item I also have problem with UTF-8 on console.. garbled characters
\pause
{\begin{itemize}
\item Then, I \texttt{export LC\mbox{\_}ALL=C}, of course I'm not happy with this
\item But most of the time, it works\ldots
\end{itemize}}
\end{itemize}
\end{alertblock}
\end{frame}
\section{Conclusion}
\begin{frame}{gettext rules}
\begin{center}
\includegraphics[scale=0.45]{./conclusion.png}
\end{center}
\end{frame}
\begin{frame}[squeeze]{fin()}
\huge
\centering{\textbf \textit{{Questions?}}}\\
\hspace{0.6cm}
\centering{
\vocalize
\setarab
\arabtrue
\begin{RLtext}hal `indakum as-su'Al?\\
\end{RLtext}
}
\hspace{1cm}
\centering{{\color{red}\texttt {najmi\mbox{\{}at\mbox{\}} kict.iiu.edu.my}}}
\end{frame}
\end{document}