A Grammatical Approach of Multi-Localization of GUIs : Application to the Multi-Localization of the Checkers Game GUI

By proposing tools that help for the accomplishment of tasks in almost all sectors of activities, computer science has revolutionized the world in a general way. Nowadays, it addresses the peculiarities of peoples through their culture in order to produce increasingly easy-to-use software for end users: This is the aim of software localization. Localizing a software consists among other things, in adapting its GUI according to the end user culture. We propose in this paper a generic approach allowing accomplishing this adaptation, even for multi-user applications like gaming applications, collaborative editors, etc. Techniques of functional interpretations of abstracts structures parameterized by algebras, constitute the formal base of our approach.


Introduction
Regarded as the fourth pillar for sustainable development [1], according to the UNESCO 1 Convention on the Protection and Promotion of the Diversity of Cultural Expressions, cultural diversity is a "world heritage" [2] and constitutes a great wealth for the people.Therefore, the protection, promotion and maintenance of cultural diversity are essentials for sustainable development for the benefit of present and future generations.Moreover, as far as computer science is concerns, one can easily agree that, a given user (a human), will use much more intuitively a software if he finds in the latter, elements that are culturally close to him as language, iconography, and the color palette used, etc. From the observations above, it is clear that it is imperative to take into account the various aspects related to cultural diversity during the development of a software.This is not only to ensure that it is built in respect of the culture of its various end users, but also to produce increasingly easy-to-use software for end users.In order to achieve these objectives, cultural computing 2 is the paradigm that should be used if we want to efficiently take into account the possible cultural diversity of end users, when producing a software tool.With this in mind, software publishers, are now using knowledge from cultural computing to improve the user's experience of each of the end users of their tools: The tool must be constructed in such a way that it is the GUI (Graphical User Interface) that adapts to the user and not the other way around.
In order to produce several (localized) versions of the same software product, publishers use two techniques: internationalization (i18n) and localization (l10n) [4] [5].Internationalization is the process of generalization which, in software design, allows abstracting it from the peculiarities of a given culture by representing intentionally the objects which it manipulates.According to Schäler [6], localisation is "the linguistic and cultural adaptation of digital content to the requirements and locale of a foreign market, and the provision of services and technologies for the management of multilingualism across the digital global information flow".
In order to perform a linguistic and cultural adaptation of an application, among other activities, its GUIs must be translated to the signifiers, the habits, etc of targets cultures.Figure 1 presents two located examples of George Weah's bibliography in Wikipedia for Francophone culture 3 (Figure 1(a)) and for Arab culture 4 (Figure 1(b)).On these figures, we can notice some differences concerning the language used, the position of images and menus, colors, etc.
Most single-user software used around the world are not located.It's even worse when you consider the case of those running on a network 5 , because for such applications, it might be ideal to offer to each application user at a given time, a GUI who is consistent with its own culture.For example, it's about designing a multiplayer game or a collaborative editing application so that, each participant interacts on a located GUI in their culture.This is what we call 2 The goal of cultural computing is to "addresse underlying and almost unconscious cultural determinants that have since ancient times a strong influence on our way of thinking, feeling and worldview in general" [3].As far as GUI is concerns, it allows the end user of a given software to experience an interaction closely related to the fundamental aspects of his culture.Journal of Software Engineering and Applications Starting from the observation that the tree structure of a GUI can be represented intentionally by an abstract syntax tree (AST) for a given context-free grammar (see Section 2.1), we borrow techniques and tools from the domains of language theory, compilation, and functional programming, to show that, a particular localization of a GUI represented intentionally by an AST, is in fact only a particular interpretation of this AST according to a given algebra: this is the formal base on which our multi-localization approach is based.More precisely, from an abstract grammar (AST's model of GUIs of a given application), we deduce: 1) Haskell data types 6 [7] [8] for each of its grammatical symbols, 2) types for algebras that will be use to write as many interpreters as wanted, in as many GUI description languages (FXML7 [9], UIML [10], etc.), 3) evaluation functions, each parameterized by both an algebra and a localization file which will make it possible to locate the AST by interpretation.A synoptic view of the proposed approach is sketched in Figure 2.
Organization of the manuscript: Section 2 introduces some concepts related to software localization and GUI modeling using context-free grammars (CFG).
Our multi-localization approach, followed by its experimentation (derivation of multi-located GUIs for a network checkers game) is presented in Section 3, while Section 4 is devoted to the conclusion.

Context-Free Grammars as GUI's Models
A graphical window (GUI) consists of a set of basic components8 (Image, Menu,  Haskell is a functional programming language who is used (without prejudice to the generality) as the supporting functional language of this presentation.
Figure 2. A synoptic view of the proposed multi-localization approach.
etc.) to a precise positions on the window by means of the so called structural components 9 [11] [12].Presented this way, one can easily realize that, the rules governing the grouping of the (basics and/or structural) components of a GUI can be described using the production rules of a CFG.Therefore, a GUI (tree structure) can be intentionally represented by an AST of a CFG.In fact, for a given graphical application, we can construct a CFG in such a way that, any of its GUIs is intentionally represented by an AST of the latter (see Section 3.2.1):CFG can be used as models of the GUIs of an application.This is the use made of it in this paper.
Recall that a CFG defines the structure of its instances (AST) by means of productions.A production, generally denoted Definition 1 An abstract context free grammar (CFG) is given by ( )   composed of a finite set  of grammatical symbols or sorts corresponding to the different syntactic categories involved, a particular grammatical symbol A ∈  called axiom, and a finite set , : , P denotes the length of its right hand side and ( ) lhs P (resp.

( )
rhs P return its left (resp.right) hand side.A production with the symbol X as left part ie.
( ) = lhs P X , is called a X-production.An AST is a tree whose nodes are labeled by the grammatical symbols of the grammar and is such that, for any internal node labeled X , having n sons la- beled must be a grammar production.Moreover, the leaf nodes must be associated with ε -productions.
Definition 2 The set ( ) of abstract syntax trees according to the grammar  associated with grammatical symbol X consists of trees in the form where X is the label of the root node10 of the tree, 1 n t t  are subtrees of the root node and there is a production ( ) AST can be interpreted as evidence of the conformity of the GUI (tree structure) with the grammar.

On Software Localization: External vs. Inner Localization
The localization of a software does not only concern its GUIs.This is an activity that also includes the technical documentation provided with the software (installation guides, user manuals, etc.), online help and so on [13].
When the need to locate softwares was felt, the first answer given to this new challenge by the software publishers was purely linguistic and recommended working directly on the source code of the application: this is what we call inner software localization [4].Since the strings to be translated are generally scattered throughout the application's code, the localizer must have access to it.The latter must then be either a translator with programming knowledge, or a programmer with translation knowledge, or both must work in perfect intelligence.
Granting free access to the source code to a third party who is not the editor poses at least the problem of security and confidentiality.Indeed, since translators do not generally have a great programming knowledge, the risk is great that they inadvertently modify, or copy for unconfessed purposes the source code available to them for translation [4].
In the early nineties, a new form of localization using resource files 11 and called external software localization [14] has been created.It allows translators to process the text contained in the GUIs without need to have any particular programming knowledge, or to constantly need the assistance of the programmers.
They only intervene on the resource file (containing localizations of localizable elements such as text, etc.) which is subsequently delivered with the software product.In production, the choice of the localization to use for a particular running of the software is done either interactively at the start of the software, or is previously set in a configuration file.By doing so, the software developed is not only completely independent of the end user culture, but is also highly extensible from a localization perspective.Indeed, it is enough to create a new localization file containing data relating to a new culture, for it to be taken into account by the tool.Journal of Software Engineering and Applications Recall that the work presented in this manuscript focuses exclusively on the external localization of GUIs.

Derivation of a (Parameterized) Functional Interpreter of ASTs
We have seen (section 2.1) that the logical structure of a GUI can be represented by an abstract CFG.

Let
( ) : , : , , : , be a grammatical model of GUIs of a software.We present in this subsection how to encode 1  , its ASTs as well as their interpreters in the functional language Haskell.
Well-known techniques describing how to carry out a functional implementation of a CFG, and how to write interpreters of its ASTs exist [15] [16].We briefly present below how we proceed.Note that, our way of doing things is not fundamentally different from others but has the advantage of being modular.Indeed, whereas generally a single algebra structure is associated with a grammar, we suitably associate an algebra structure with each syntactic category of the grammar and consider in fine that, the algebra structure associated with the grammar is the one associated with its axiom.
Abstract grammar allows to specify syntactic structures that can be associated in Haskell to a set of algebraic data types 12 describing the different syntactic categories used in grammar.Terms of a data structure are generally subject to several interpretations, all of them following the same recursion pattern.This is why they are generally specified by means of algebras 13 formally defined as follows: Definition 3 Let ( )   be a CFG.An algebra X  associated with a grammar symbol X ∈  is given by: 1) an interpretation domain Y D asso- ciated with each grammar symbol Y appearing in a X -production of  , 2) a reference to the Z  algebra of each grammar symbol Z appearing on the right-hand side of a X -production. 3)an application is the one associated with his axiom A : , we deduce from systematic way the Haskell data types, the associated algebra data types, and the evaluation functions (catamorphisms 14 ) as follows: 1) A data type is created for each grammar symbol.
2) For each created data type, an associated algebra data type is created.It consists of two groups of selectors:  The group formed by types of interpretation functions of algebraic data type: there is one for each data constructor of algebraic data type,  The group containing references to algebras associated with the different algebraic data types used in the definition of the type of which the current algebra is associated.
3) For each data type created, an evaluation function encapsulating the recursion pattern is created; it is parameterized by the algebra associated with this data type.
Application of the approach to the grammar 1  1) Creating data types: 2) Creation of data types for algebras: X i D denotes the type variable representing the interpretation domain of the type i X .
3) Evaluation function parameterized by algebra data type associated to X data type 15 .

A Multi-Localization Approach: The Steps
In order to be intensively localizable, GUIs have to be internationalised to abstract any information directly related to a culture.This justifies the decomposition of our multi-localization approach into two phases: an internationalization phase whose objective is to produce a grammatical model (an abstract grammar) of all the GUIs of the software; followed by a phase of multi-localization, whose objective is to produce on the fly, located GUIs for each of the participants in the collaboration.

The Internationalization Phase
The internationalization phase can be considered as an analysis-design phase, allowing not only to identify the localizable elements of the GUIs for the abstraction purpose, but also to highlight the structural relations which exist between them.Only a summary description of this phase is given below, because it is not the main object of this study.It takes place in four steps: 1) Sketching: produce a sketch of all the GUIs of the software.This can be done because, this set is finished.
2) Identification: identify for each GUI the localizable elements for their abstraction; symbolic names will be found and only one occurrence of similar elements appearing in more than one GUI is retained.
3) Production of ASTs: identify the structural relationships between localizable elements of the GUIs and for each relation identified, study constraints related to the relationship; for example, the meaning of the relation that can be different from one culture to another, etc.This step ends with the production of an AST draft for each GUI: this is its intentional representation. 4)Derivation of the grammar model of the application's GUIs: from the different ASTs produced in the previous step, derive their CFG by considering that, the set of AST's labels form the set of grammatical symbols and that, a label of a inner node and those of its directs children form a production.

The Multi-Localization Phase
This phase starts after the previous one and takes as input the grammar produced.It takes place in three steps (see Figure 2): 1) Generation of data structures: generate from the grammar data structures, algebras data structures and evaluation functions for each grammatical symbol (Figure 2-Step1) as described in section (see section 3.1).
2) The choice of GUIs description language(s) and cultures to be located: the produced GUIs are described in a (textual) language like FXML [9], UIML [10], etc.An implementation of algebra must therefore be provided for each of the target GUI (textual) description languages.Likewise, a localization file must be produced for each target culture (Figure 2-Step2).
3) Multi-localization: at the running time, the located GUI is obtained by invoking the evaluation function associated with the axiom of the grammar.An instance of algebra corresponding to the desired description language, and the Journal of Software Engineering and Applications localization file related to the target culture are provided as effective parameters during this invocation (Figure 2-Step3).
External localization of software uses resource files that can be in the binary (.DLL, .EXE, etc.) or text format.In the following, we will call localization file a text resource file, containing in addition to strings to display in the GUI (linguistic aspect), other cultural information (color codes, disposition order of components, etc.) whose suitable use by the ASTs interpretation functions will provide a located GUI in which, not only linguistic concerns are addressed.
A localization file is structured in sections, and each of them contain information about a specific cultural concern addressed (language, color, components layout, etc.).Each section is structured as an associative list, ie. a list of pairs (key, value) where key is the identifier of a resource (its internationalized form), and value its concrete representation in the current target culture.We have on the listing 6 an example of a localization file.

Experimentation: Application to the Multi-Localization of the Checkers Game GUI
Recall that checkers game consists of a set of pieces that moves according to precise rules, on a checkerboard made up of 100 squares.It is played by at least 2 players and each player has 20 pieces of single color, which is distinct from the color of pieces of the other player.The goal of checkers game is to take or block the largest number of opposing pieces.
Considering that a checkers game can only be played by at least 2 players, it can be implemented and played in a network: it is therefore a kind of cooperative application.One can easily imagine a checkers game played by participants belonging to different cultural areas.As mentioned in the introduction (Section 1), the game's GUI can be multi-located in order to improve for each player his application's use comfort: each of the participants will then interact on a located GUI relating to his culture.The rest of this subsection presents how this goal can be achieved by applying the multi-localization approach described in Section 3.2.Note that our goal here is not to build a fully functional checkers game, but, to present how our approach can easily derive a multi-located GUI for the latter.For a better understanding of the example, we presented on Figure 3, the orchestration diagram summarizing the interaction between different players during a game: any action of a player (moving a piece) on his GUI is raised at the AST level and the GUI of the other player is immediately updated accordingly; bidirectional binding [17] is implemented between each localized GUI and the AST.

Localizable Elements and AST of the Checkers Game
For illustration purposes, we have retained in addition to the GUI components related to the linguistic aspect, some others whose interpretation may vary from one culture to another.Finally, the localizable elements selected for our toy application are: strings (the linguistic aspect), colors, images of the pieces, layout From the abstraction of its elements and the structural relations that can be identified between them, we have the AST of Figure 4 in which, the components Label, Button, ImageView, TextField (resp.Vbox, Hbox, Gridpane) are abstractions of basic (resp.structuring/layout) components that names are related to those that we generally have in the GUI's build libraries.

GUI's Grammar for the Checkers Game
From the abstract representation of checkers game (Figure 4) one can derive abstract grammar whose productions (an extract) are presented on the listing 1.
Listing 1: GUI's grammar for the checkers game Figure 4.An example of a simplified AST representing the GUI of a checkers game.
In the listing 1, grammar symbols that do not appear on the left hand side of any production are assumed to be associated with ε -productions (not shown in this listing).In addition, in line 3, the notation "*" simply means that the grammar symbol Vbox is used to structure zero or more BaseCompOrGroup components.

Data Structures Derived from the Grammar of the Listing 1
An extract is given in the listing 2. Note that, a flat must be made to what have been said in Section 3.1 with regard to the data types to create.In fact, we will not create neither a Haskell data type nor algebra for grammatical symbols that we call linguistic symbols; these are symbolic names whose concrete value in the language of target culture is given in the localization file.In the listing 1, these are the grammatical symbols whose names have ".game" as extension; they are represented by the type String (their domain of interpretation) in the listing 2, lines 7 and 8.
Listing 2: Data structures derived from the grammar of the listing 1 Journal of Software Engineering and Applications Listing 3 presents the Haskell code of the algebraic structures associated with the data types of the listing 2. In this one, the types variables Vbox D , Hbox D , Ast D , etc. represent the interpretation domains of the respective components, Vbox, Hbox, Ast, etc.Note that, the interpretation functions of derived algebraic structures, use data contained in the localization file.The latter is therefore provided as a parameter (listing 3, lines 7 and 10), and treated as an inherited attribute 16 associated with all the syntactic categories of the grammar.
During the scanning of a linearization of the AST, the checkers board is generated when GridPane is met.The syntactic categories BaseCompOrgroup, Ba-seComp and Ast are used only for factorisation purposes (reducing the number of productions), the interpretation functions of algebra that are associated do not use data contained in the localization file: they do not take it as a parameter as it is the case for other algebras.
Listing 3: Some algebras structures derived from the grammar of the listing 1 As for the interpretation functions of algebras, the evaluation functions parameterized by algebras (listing 4) use data contained in the localization file; it is therefore provided as a parameter to these functions, and they must propagate it in the AST, by making them available at the level of each of their sons (listing 4, line 4).
Listing 4: The catamorphisms associated with the algebras of the listing 3

An Implementation of Algebra for FXML
For the checkers game, we chose FXML as the GUI description language.All syntactic categories, except those qualified as linguistic symbols, therefore have 16 In the attributed grammars, the inherited attributes allow among other things to propagate information from the root to the leaves of a tree.approach may allow even a non-computer specialist to increment the localization degree (adding a new culture) of a software as soon as it has already been located for at least one culture: It is enough for that to adequately create a new localization file for the new target culture.Note however that, the creation of the new file will be easier if one can do it by the mean of a DSL (Domain Specific Language) [18]; this is one of the immediate perspectives of this work: that is, to investigate about an implementation of the proposed method as a software system, that generate code from high-level description, in order to not leave too much manual low-level writing of boilerplate code (like the one in the listing 5) to the software developer.

Figure 1 .
Figure 1.Bibliography of George Weah in Wikipedia: (a) for French culture, (b) for Arab culture.
assimilated in the GUIs context, to a structuring rule showing how the component 0 X , lo- cated on the left hand side of the production, allows structuring/grouping the other components 1 n X X  located on the right hand side.More formally, we have the following definition: Catamorphisms cataX:: FL->AlgX->X->dSemX cataY:: FL->AlgY->Y->dSemY

Figure 3 .
Figure 3. Orchestration diagram modeling the interaction between two checkers players.

Figure 5 .
Figure 5. Multi-localization of the AST of Figure 4: (a) localization in a "Western like culture", (b) localization in an "African like culture".

Table , Text
Box, etc.), arranged in relation to each other (horizontally, vertically,