Second Language Linux Is International

Total Page:16

File Type:pdf, Size:1020Kb

Second Language Linux Is International PROGRAMMING Bilingual Programming Bilingual Programming Second language Linux is international. It was started by a programmer from Finland who speaks Swedish. Aided by a Welsh- speaking lieutenant. Supplemented with a kernel maintainer from Brazil. So why is all our software written in English? This month multi-lingual development and the gettext package. BY STEVEN GOODWIN he English language holds the same Turning Japanese equivalent by using the code in box: In power in today’s society that Latin GNU/Linux uses a technique known as PHP. Tdid many hundreds of years ago. locales to determine many things: the It’s not the most expressive language, nor appropriate translations for text, the #include <stdio.h> is it the most popular. It certainly isn’t character set required to represent the int main(int argc, char *argv[]) the easiest to learn. It is, however, the alphabet, and cultural specifics like the { most widespread. With the remnants of expression of numbers, or the date. Each printf("Hello World!\n"); the old British Empire still present, and area is considered in the box: Locale Cat- return 0; the continued growth of America, people egories, although the focus of this article } are required to use English in order to will be on text translation. compete on the world stage. So let us start with the simplest pro- It’s fairly obvious to us where the transla- Computers and the Internet have gram we know, Hello World. We shall be tion string will need to go. At compile increased this linguistic strangle-hold. coding in C, although the same tech- time, however, we do not know what the More web pages exist in English than any niques can be applied regardless of replacement string will be, or what lan- other language. More programming lan- language. You’ll be able to test the PHP guages it will need to be in. This prevents guages use English words like if and us from including any translation data while, regardless of the designer’s nation- In PHP directly into program. Instead, we must ality. Most software uses prompts and Writing multi-lingual software in PHP is no build up catalogs of each word and error messages that are written in English. different from using C.The functions even phrase used by our program, and employ However, with Linux taking control of have the same name! However,when run as the gettext package to act like a dictio- many different systems across the globe, part of a web page,it might be more suit- nary. This will replace our (English) it would appear to be xenophobic of us able to specify the locale explicitly.Perhaps words with the correct foreign version at to continue developing ‘English-only’ coming from an session variable,or cookie run time. What is ‘correct’ will be deter- software. Adding the ability to change on the users machine. mined by the user’s specific locale. the language (or locale) of your software <?php We are required to do two things, is not a difficult task to achieve, but it setlocale(LC_ALL, "fr_FR"); 1. Mark the source code to say ‘get me shows a wider commitment to your pro- textdomain("lm"); the correct words for the phrase XYZ’ echo gettext("Hello World!\n"); ject, and the open source community in 2. Build a translation dictionary for ?> general. Even if you can not translate the each language we need to support The effect of setlocale can also be achieve by text yourself, you can make it easier for using the putenv function. Marking the source is a simple someone else to do so by following the process. We, as programmers, must work putenv ("LANG=fr"); guidelines in this article. through each line of the code and indi- 66 June 2004 www.linux-magazine.com Bilingual Programming PROGRAMMING cate which lines of text will need trans- translated. We shall shortly see a tool that lating. We can do this by calling a special makes use of these markers itself to help Locale Categories function (called, not surprisingly, build the dictionary of translations. If we A category defines a set of data,and every supported language has its own set of data. gettext) that will consult the dictionary were to build the dictionary manually The category might define the way to and convert our string to something suit- (but why would we?!), the gettext_noop impart particular information:numbers ably foreign. marker would be unnecessary. over 1000 might be separated by commas or Some programmers prefer to replace dots,for example,or the date might be writ- printf(gettext("Hello U this nine character marker with a single ten day-month-year or month-day-year.This World!\n")); character macro, such as the underscore. information is not related to the language This is because the word gettext (and as such,which is why the term ‘locale’is used,constituting both language and cul- This function can be found in the libintl both brackets) can cause many lines to tural specifics. A directory is created for each header file, so we must, break the 80 character limit. This is sim- category. ply, There are standard functions to format #include <libintl.h> these locale strings. For example,strfmon #define _(str) gettext (str) and strftime format the text for money and Compiling under GNU/Linux requires no #define N_(str) gettext_U time data,respectively. extra link libraries for the code to work. noop (str) Category Meaning The word GNU is essential here. That is LC_COLLATE Order of string-collation because the internationalization features The GNU standard prefers a space LC_CTYPE How to define characters. Echoes of are included directly in glibc. Users of between function name and bracket, but ctype.h as this also performs upper/ other Unix-like systems may not be so this is often omitted. lower case conversion lucky. However, without a language cata- We can now move on and build our LC_MESSAGES The translated text.The focus of this article log, no translations will be made. That foreign language dictionary. LC_MONETARY Format and symbols for money doesn’t matter at the moment, since the LC_NUMERIC Format and symbols for numbers English text will be output in all cases Vienna Calling LC_TIME Format and symbols for time and date where a translation can not be found. C Building a file that contains all the programmers will also note that this strings in a program is not as time-con- method is not all-encompassing, because suming as you might think. Naturally, it msgid "Hello World!\n" there is more than one way to declare a is a very common task, and can be msgstr "" string. However, we’ve only learnt one achieved by using a tool named xgettext. way to mark strings for translation. So This is one of the few instances where As you can see, each piece of text has a we will need to use another method, to the ‘x’ does not stand for an X Window marker ID and an equivalent string, cope with those cases where a function program. Instead, it is short for ‘extract’. ready for translating. This string can call to gettext would result in a syntax This program will search the source file only hold a translation for one specific error. For example, for any string used in conjunction with language, so this file becomes a tem- the function call gettext (or gettext_noop) plate. Each translator takes a copy of it, char *pHello = "Hello, U and place the text into a catalog file and translates the text within it to his or World!\n"; (ending the suffix .PO) ready to be trans- her native tongue. Sometimes, this PO lated. The program understands enough file is renamed to POT to differentiate To circumvent this problem, we need to about C, and about other languages (see between the template, and the language- create a macro that includes a marker, box: xgettext: Supported Languages), to specific catalog files. but has no adverse effect on the syntax. understand the syntax of a function call, Note that xgettext will search for the and differentiate it from variables and function name gettext. It does not under- #define gettext_noop(String) U comments. stand enough of the C syntax (or that String any language) to understand techniques ... $ xgettext -d lm helloworld.c like #define _(str), given above. This char *pHello = gettext_noop("U $ tail -n 3 lm.po doesn’t preclude the use of such tricks Hello, World!\n"); #: helloworld.c:5 however. There are two popular solu- tions. One is to specify the underscore as We then need to invoke the translation xgettext: Supported an additional keyword that will act in the module in the usual way, before we out- Languages same manner as if it were gettext. put the string. Like so, C,C++,ObjectiveC awk $ xgettext -d lm -k_ U PO YCP printf (gettext (pHello) ); helloworld.c Python Tcl Lisp,EmacsLisp RST These markers not only perform the Alternatively, you could pre-process translation when the program is running, librep Glade your C file (causing the macro to be but indicate to us what text needs to be Java expanded) before running xgettext. www.linux-magazine.com June 2004 67 PROGRAMMING Bilingual Programming $ xgettext -C -d lm <(gcc -E U which highlights the deliberate mistake localedirectory, be careful not to change helloworld.c) above. Did you spot it? See Listing 1. directory, as this path would then The first warning simply reminds us become unreachable. In this example we specify the -C flag , to that we haven’t changed the header While in our local root directory, we indicate that the piped result is a C information yet.
Recommended publications
  • Download the Specification
    Internationalizing and Localizing Applications in Oracle Solaris Part No: E61053 November 2020 Internationalizing and Localizing Applications in Oracle Solaris Part No: E61053 Copyright © 2014, 2020, Oracle and/or its affiliates. License Restrictions Warranty/Consequential Damages Disclaimer This software and related documentation are provided under a license agreement containing restrictions on use and disclosure and are protected by intellectual property laws. Except as expressly permitted in your license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any means. Reverse engineering, disassembly, or decompilation of this software, unless required by law for interoperability, is prohibited. Warranty Disclaimer The information contained herein is subject to change without notice and is not warranted to be error-free. If you find any errors, please report them to us in writing. Restricted Rights Notice If this is software or related documentation that is delivered to the U.S. Government or anyone licensing it on behalf of the U.S. Government, then the following notice is applicable: U.S. GOVERNMENT END USERS: Oracle programs (including any operating system, integrated software, any programs embedded, installed or activated on delivered hardware, and modifications of such programs) and Oracle computer documentation or other Oracle data delivered to or accessed by U.S. Government end users are "commercial
    [Show full text]
  • Potranslator Documentation Release 1.1.5
    potranslator Documentation Release 1.1.5 SekouD Nov 01, 2018 Contents 1 potranslator 3 1.1 Supported Languages..........................................3 1.2 Quick Start for auto-translation with potranslator............................6 1.3 Basic Features..............................................7 1.4 Optional features.............................................7 1.5 Installation................................................8 1.6 Commands, options, environment variables...............................8 1.7 License..................................................9 1.8 Original..................................................9 1.9 CHANGES................................................9 2 Installation 11 2.1 Stable release............................................... 11 2.2 From sources............................................... 11 3 Usage 13 3.1 From a Python program......................................... 13 3.2 Commands, options, environment variables............................... 13 4 Package Api Documentation for potranslator 17 4.1 API Reference for the classes in potranslator.potranslator.py...................... 17 5 Contributing 19 5.1 Types of Contributions.......................................... 19 5.2 Get Started!................................................ 20 5.3 Pull Request Guidelines......................................... 21 5.4 Tips.................................................... 21 5.5 Deploying................................................ 21 6 Credits 23 6.1 Development Lead...........................................
    [Show full text]
  • GNU Guix Cookbook Tutorials and Examples for Using the GNU Guix Functional Package Manager
    GNU Guix Cookbook Tutorials and examples for using the GNU Guix Functional Package Manager The GNU Guix Developers Copyright c 2019 Ricardo Wurmus Copyright c 2019 Efraim Flashner Copyright c 2019 Pierre Neidhardt Copyright c 2020 Oleg Pykhalov Copyright c 2020 Matthew Brooks Copyright c 2020 Marcin Karpezo Copyright c 2020 Brice Waegeneire Copyright c 2020 Andr´eBatista Copyright c 2020 Christine Lemmer-Webber Copyright c 2021 Joshua Branson Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled \GNU Free Documentation License". i Table of Contents GNU Guix Cookbook ::::::::::::::::::::::::::::::: 1 1 Scheme tutorials ::::::::::::::::::::::::::::::::: 2 1.1 A Scheme Crash Course :::::::::::::::::::::::::::::::::::::::: 2 2 Packaging :::::::::::::::::::::::::::::::::::::::: 5 2.1 Packaging Tutorial:::::::::::::::::::::::::::::::::::::::::::::: 5 2.1.1 A \Hello World" package :::::::::::::::::::::::::::::::::: 5 2.1.2 Setup:::::::::::::::::::::::::::::::::::::::::::::::::::::: 8 2.1.2.1 Local file ::::::::::::::::::::::::::::::::::::::::::::: 8 2.1.2.2 `GUIX_PACKAGE_PATH' ::::::::::::::::::::::::::::::::: 9 2.1.2.3 Guix channels ::::::::::::::::::::::::::::::::::::::: 10 2.1.2.4 Direct checkout hacking:::::::::::::::::::::::::::::: 10 2.1.3 Extended example ::::::::::::::::::::::::::::::::::::::::
    [Show full text]
  • Using Ptxdist on Mac OS Based on Ptxdist 2012.04
    Using PTXdist on Mac OS based on PTXdist 2012.04 Bernhard Walle∗ 2012-04-20 ∗[email protected] Contents 1. Motivation 3 2. Basics 4 2.1. Getting OpenSource Software on Mac OS.........................4 2.2. Preparing the Hard Disk..................................5 2.2.1. Creating and Using a Sparse Bundle ........................6 3. Installing PTXdist7 3.1. Requirements........................................7 3.1.1. Mac OS.......................................7 3.1.2. Host compiler....................................7 3.2. GNU Tools..........................................7 3.3. Installation..........................................8 3.4. First setup..........................................9 4. Building an OSELAS.Toolchain 11 5. Building an Embedded Linux project 12 5.1. Using OSELAS.BSP-Pengutronix-Generic......................... 12 5.1.1. Getting the BSP................................... 12 5.1.2. Building FSF GCC.................................. 13 5.1.3. Building Qemu................................... 13 5.1.4. Running the System................................ 13 5.2. Using real Hardware.................................... 14 6. Limitations 15 6.1. Building UBI or JFFS2 images................................ 15 6.2. Linux kernel......................................... 15 6.3. Bootloader.......................................... 15 7. Using a Mac for Embedded Linux Development 16 7.1. Using a serial console.................................... 16 7.2. Exporting directories via NFS............................... 16 7.3. Mounting ext2 partitions.................................. 18 A. About this Document 19 B. Change History 20 Bibliography 21 2 1. Motivation PTXdist (http://www.ptxdist.org) is a great way to build Embedded Linux systems. It downloads all required components, conVgures them for cross-compilation and Vnally builds a target image and/or target packages. In addition, it provides an easy way to build a cross-toolchain for most common processors. Read [2] for a description how to use PTXdist.
    [Show full text]
  • Open Source License and Copyright Information for Gplv3 and Lgplv3
    Open Source License and Copyright Information for GPLv3/LGPLv3 Dell EMC PowerStore Open Source License and Copyright Information for GPLv3/LGPLv3 June 2021 Rev A02 Revisions Revisions Date Description May 2020 Initial release December 2020 Version updates for some licenses, and addition and deletion of other components June, 2021 Version updates for some licenses, and addition and deletion of other components The information in this publication is provided “as is.” Dell Inc. makes no representations or warranties of any kind with respect to the information in this publication, and specifically disclaims implied warranties of merchantability or fitness for a particular purpose. Use, copying, and distribution of any software described in this publication requires an applicable software license. Copyright © 2020-2021 Dell Inc. or its subsidiaries. All Rights Reserved. Dell Technologies, Dell, EMC, Dell EMC and other trademarks are trademarks of Dell Inc. or its subsidiaries. Other trademarks may be trademarks of their respective owners. [6/1/2021] [Open Source License and Copyright Information for GPLv3/LGPLv3] [Rev A02] 2 Dell EMC PowerStore: Open Source License and Copyright Information for GPLv3/LGPLv3 Table of contents Table of contents Revisions............................................................................................................................................................................. 2 Table of contents ...............................................................................................................................................................
    [Show full text]
  • Functional Package and Configuration Management with GNU Guix
    Functional Package and Configuration Management with GNU Guix David Thompson Wednesday, January 20th, 2016 About me GNU project volunteer GNU Guile user and contributor since 2012 GNU Guix contributor since 2013 Day job: Ruby + JavaScript web development / “DevOps” 2 Overview • Problems with application packaging and deployment • Intro to functional package and configuration management • Towards the future • How you can help 3 User autonomy and control It is becoming increasingly difficult to have control over your own computing: • GNU/Linux package managers not meeting user needs • Self-hosting web applications requires too much time and effort • Growing number of projects recommend installation via curl | sudo bash 1 or otherwise avoid using system package managers • Users unable to verify that a given binary corresponds to the source code 1http://curlpipesh.tumblr.com/ 4 User autonomy and control “Debian and other distributions are going to be that thing you run Docker on, little more.” 2 2“ownCloud and distribution packaging” http://lwn.net/Articles/670566/ 5 User autonomy and control This is very bad for desktop users and system administrators alike. We must regain control! 6 What’s wrong with Apt/Yum/Pacman/etc.? Global state (/usr) that prevents multiple versions of a package from coexisting. Non-atomic installation, removal, upgrade of software. No way to roll back. Nondeterminstic package builds and maintainer-uploaded binaries. (though this is changing!) Reliance on pre-built binaries provided by a single point of trust. Requires superuser privileges. 7 The problem is bigger Proliferation of language-specific package managers and binary bundles that complicate secure system maintenance.
    [Show full text]
  • Translate's Localization Guide
    Translate’s Localization Guide Release 0.9.0 Translate Jun 26, 2020 Contents 1 Localisation Guide 1 2 Glossary 191 3 Language Information 195 i ii CHAPTER 1 Localisation Guide The general aim of this document is not to replace other well written works but to draw them together. So for instance the section on projects contains information that should help you get started and point you to the documents that are often hard to find. The section of translation should provide a general enough overview of common mistakes and pitfalls. We have found the localisation community very fragmented and hope that through this document we can bring people together and unify information that is out there but in many many different places. The one section that we feel is unique is the guide to developers – they make assumptions about localisation without fully understanding the implications, we complain but honestly there is not one place that can help give a developer and overview of what is needed from them, we hope that the developer section goes a long way to solving that issue. 1.1 Purpose The purpose of this document is to provide one reference for localisers. You will find lots of information on localising and packaging on the web but not a single resource that can guide you. Most of the information is also domain specific ie it addresses KDE, Mozilla, etc. We hope that this is more general. This document also goes beyond the technical aspects of localisation which seems to be the domain of other lo- calisation documents.
    [Show full text]
  • Design and Implementation of an End-User Programming Software System to Create and Deploy Cross-Platform Mobile Mashups
    Degree Project Design and implementation of an end-user programming software system to create and deploy cross-platform mobile mashups Sandra Kaltofen 2010-11-09 Subject: Computer Science Level: Bachelor Course code: DA3003 Abstract Significant changes in mobile computing are continuously influenced by the enhanced features of mobile devices and software applications. The release of open platforms that allow the creation of advanced mobile applications are the triggers for recent developments with regard to the topics of end-user mobile application frameworks and mobile mashup creation. Inspired by these efforts, this thesis identifies some of the problems in this field and presents a solution for a cross-platform end-user programming software system that enables the creation of mobile mashups. Keywords: Android, Cross-platform mobile frameworks, Google Web Toolkit, iPhone, Java, JavaScript, Mashups, Mobile mashups, Web 2.0 APIs, Web development frameworks ii Table of Contents 1 Introduction ................................................................................................................ 1 1.1 Definition of the problem .................................................................................... 3 1.2 Structure of the thesis .......................................................................................... 3 1.3 Delimitations ....................................................................................................... 4 2 State of the art............................................................................................................
    [Show full text]
  • C/C++ Compile Guide
    WizFi630S Guide C/C++ Compile Guide (Version 1.0.0) © 2019 WIZnet Co., Ltd. All Rights Reserved. For more information, please visit our website at http://www.wiznet.io/ © Copyright 2019 WIZnet Co., Ltd. All rights reserved. 1 WizFi630S Guide Document Revision History Date Revision Changes 2019-11-25 1.0 Release © Copyright 2019 WIZnet Co., Ltd. All rights reserved. 2 WizFi630S Guide Contents 1. Overview ................................................................................................................. 4 2. Download ................................................................................................................ 4 2.1 Prerequisites .................................................................................................. 4 2.2 Packages for Building Environment .......................................................... 4 2.3 OpenWRT Firmware Repository................................................................. 6 2.4 Menuconfig .................................................................................................... 7 3. Write C Code........................................................................................................... 7 3.1 Helloworld ...................................................................................................... 7 3.2 Make the Environment Script .................................................................... 8 4. Cross Compile ......................................................................................................... 8 4.1
    [Show full text]
  • Enhancing Open-Source Localization
    San Jose State University SJSU ScholarWorks Master's Projects Master's Theses and Graduate Research 2010 Enhancing open-source localization Farzana Forhad San Jose State University Follow this and additional works at: https://scholarworks.sjsu.edu/etd_projects Part of the Computer Sciences Commons Recommended Citation Forhad, Farzana, "Enhancing open-source localization" (2010). Master's Projects. 57. DOI: https://doi.org/10.31979/etd.5kf8-9ykm https://scholarworks.sjsu.edu/etd_projects/57 This Master's Project is brought to you for free and open access by the Master's Theses and Graduate Research at SJSU ScholarWorks. It has been accepted for inclusion in Master's Projects by an authorized administrator of SJSU ScholarWorks. For more information, please contact [email protected]. Enhancing open-source localization CS298 Report Enhancing open-source localization A Writing Project Presented to The Faculty of computer Science San Jose State University In Partial Fulfillment of the Requirement for the Degree Master of Science By Farzana Forhad May 2010 - 1 - Enhancing open-source localization CS298 Report © 2010 Farzana Forhad - 2 - Enhancing open-source localization CS298 Report APPROVED FOR THE DEPARTMENT OF COMPUTER SCIENCE Dr. Chris Pollett Dr. Robert Chun Frank Butt - 3 - Enhancing open-source localization CS298 Report ABSTRACT Pootle is a web portal which is designed to be a web translation tool. We can run Pootle like an internet server and run a local copy on an intranet. Pootle has a user friendly interface which ensures better quality and easier translation of projects. Users can log into the Pootle and create their own projects under any language, and they can also add or retrieve any language from any project or any project from any language.
    [Show full text]
  • If Loop in Unix Shell Script Examples
    If Loop In Unix Shell Script Examples Flin remains merging: she bays her plica fumigating too resistively? Denticulate and old-established Harvie never cross-sections deridingly when Job invalid his focussing. In-and-in Bentley plebeianizing munificently or yarns dithyrambically when Wynton is isobaric. This type of unix shell A Unix shell or both a command interpreter made a programming language. You jump to swallow a little between check and statement. If ear is no existing variable, simply sit them. If possible example that first file to be processed is programc the puppet will expand. UK on bash if statement with array passport risk my application. You have modified version will be looping in localstorage so on your system, a false condition can we have. Yes there are often loops, unix shell script! The example shell? Bash IF Syntax & Examples Tutorial Kart. Without this capability, so assignments to this variable have no effect. We shall learn about the syntax of if statement and get a thorough understanding of it with the help of examples. First cell's just rise at the example given case and fang a goto statement in story that maybe you choose a. How deeply your loop examples are converted files can be looping? Introduction to if. Kill ring into words and letters and in unix shell and osx in if performance, loop in script if there is discussed in groups of. The loop through a numeric operations on ibm kc alerts notifies you might think that did not append a digit. From chart above examples of the conditional statement if, those need shell! Instead, here time will teach a quick method, this use does talk matter.
    [Show full text]
  • UNIX and High-Level Language Education Using Windows Operating Systems
    UNIX and High-level Language Education Using Windows Operating Systems R. W. Skeith M. A. Thornton Department of Computer Engineering Department of Electrical and Computer Engineering University of Arkansas Mississippi State University 313 Engineering Hall ECE Dept., P. O. Box 9571 Fayetteville, AR 72701-1201 Miss. State, MS. 39762-9571 [email protected] [email protected] Abstract Entering and continuing engineering students need to learn skills in the use of high-level languages and the use of the UNIX operating system [1] including the development of shell scripts. In the past, this requirement has been very challenging to educators since it requires access to a laboratory containing (sometimes expensive) computers that are UNIX-based workstations. The widespread availability of the LINUX operating system [2] helps to alleviate this problem somewhat since the operating system is free and associated high-level language compilers are also freely available through the GNU project [3]. Unfortunately, the skills required to successfully install and use LINUX often precludes its use as a classroom tool that students can easily maintain. An alternative and free solution based on the use of a UNIX emulator that runs under Microsoft Windows operating systems is described here. INTRODUCTION Recently, several UNIX emulators that are easily installed and used under the Microsoft Operating Systems (OS) commonly referred to as “Windows” have become available [4,5,6,7]. This paper describes the authors’ experiences in using these tools in an undergraduate setting for the purpose of teaching the use of UNIX and various high-level languages such as PERL, FORTRAN, C and C++.
    [Show full text]