/docs/MyDocs

To get this branch, use:
bzr branch http://darksoft.org/webbzr/docs/MyDocs

« back to all changes in this revision

Viewing changes to Development/languages/C/Samples/Locales/1.c

  • Committer: Suren A. Chilingaryan
  • Date: 2009-04-09 03:21:08 UTC
  • Revision ID: csa@dside.dyndns.org-20090409032108-w4edamdh4adrgdu3
import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdio.h>
 
2
#include <stdlib.h>
 
3
#include <locale.h>     /* setlocale */
 
4
#include <libintl.h>    /* gettext,textdomain,... */
 
5
 
 
6
main()
 
7
{
 
8
                                /* No need for memory allocations */
 
9
    char *stmp=setlocale(LC_ALL,"");            /* Setting up locale support */
 
10
    puts(stmp);                                 /* Current locale */
 
11
    textdomain("hell");                         /* .mo file name */
 
12
    stmp=gettext("Helo World");                 /* getting string from .mo */
 
13
    printf("%s\n",stmp);                
 
14
}
 
15
/*
 
16
    char *stmp=setlocale(LC_ALL,"ru");          - For Russian by default
 
17
    putenv("LANGUAGE=ru");
 
18
 
 
19
    dgettext(DomainName,String)                 - Reads string from specified
 
20
                                                domain ( ie .mo file )
 
21
    dcgettext(DomainName,String,category)       - Reads string from .mo file
 
22
                                                located in:
 
23
                                                /usr/share/locale/ru/<category>
 
24
                                                (by default: LC_MESSAGES)
 
25
    bindtextdomain(DomainName,Dir)              - Find .mo file in specified
 
26
                                                directory
 
27
    bind_text_domain_codeset(Domain,CodeSet)    - Specifiying encoding in 
 
28
                                                which messages from domain
 
29
                                                will been returned
 
30
    
 
31
    strcoll(str1,str2)                          - Comparing strings using
 
32
                                                locale configuration 
 
33
                                                (LC_COLLATE)
 
34
    strxfrm(src,dest,n)                         - Converts string str in such
 
35
                                                way, what 2 strings comparison
 
36
                                                after conversion with strcmp
 
37
                                                will return some result, as 
 
38
                                                their comparision with strcoll
 
39
                                                before conversion 
 
40
*/