amiga-news ENGLISH VERSION
.
Links| Forum| Kommentare| News melden
.
Chat| Umfragen| Newsticker| Archiv
.

amiga-news.de Forum > Programmierung > Probs mit LOCALE [ - Suche - Neue Beiträge - Registrieren - Login - ]

-1- [ - Beitrag schreiben - ]

29.08.2002, 09:05 Uhr

Micha1701
Posts: 938
Nutzer
Hallo zusammen!

Hab grad mal ein kleines Prog zum testen der LocaleFunktionen geschrieben. Sollte ja eigentlich nicht so schwer sein... ;(

Von der Elastic Images Seite hab ich den Workshop für die Catalog Dateien. Die sieht demnach ganz ok aus. Dennoch, der Debugger zeigt mir an, daß bei OpenCatalog() NULL zurückgeliefert wird. Bei GetCatalogString() wird dadurch immer der DefaultString zurückgeliefert.... ;(

SnoopDos zeigt aber an, daß der Catalog erfolgreich geladen werden konnte. Ich habe auch beide Positionen ausprobiert (PROGDIR: und LOCALE: ). Hat nichts gebracht...

Ist vielleicht doch der Catalog/cd.Datei/ct.Datei defekt oder falsch?

Hier ist erstmal der Quelltext:


code:
#include <libraries/locale.h>

#include <clib/exec_protos.h>
#include <clib/locale_protos.h>

#include <stdio.h>


#define MSG_LANGUAGE 1
STRPTR msg_language = "The selected System language is Englishn";
#define MSG_TEXT 2
STRPTR msg_text = "This text is in your languagen";
#define MSG_END 3
STRPTR msg_end = "Bye!n";


struct Library *LocaleBase = NULL;

struct Catalog *mycatalog = NULL;
struct Locale *mylocale = NULL;

main()
{
	LocaleBase = OpenLibrary("locale.library", 0);

	mylocale = OpenLocale(NULL);

	mycatalog = OpenCatalog(mylocale,"loc.catalog",OC_BuiltInLanguage, "english", TAG_END);

	printf((char *)GetCatalogStr(mycatalog, MSG_LANGUAGE, msg_language));

	CloseCatalog(mycatalog);

	CloseLocale(mylocale);

	CloseLibrary(LocaleBase);
}



Hier folgt die CD-Datei


code:
;
;loc-Catalog V1.0 (29.08.2002)
;
MSG_LANGUAGE (0/1/)
The selected System language is Englishn
;
MSG_TEXT (1/1/)
This text is in your languagen
;
MSG_END (2/1/)
Bye!n
;



Und die CT-Datei


code:
##version loc 1.0 (28.08.2002)
##codeset 0
##language deutsch
;
MSG_LANGUAGE
Die verwendete Systemsprache ist Deutsch.n
;
MSG_TEXT
Dieser Text ist in Ihrer Sprache.n
;
MSG_END
Tschüß!n
;



Und fällt da irgendwas ins Auge?


--
:boing: Micha :boing:

Look at my HP: http://www.lanser-online.de.vu

[ Dieser Beitrag wurde von Micha1701 am 29.08.2002 editiert. ]

[ - Antworten - Zitieren - Direktlink - ]

29.08.2002, 09:41 Uhr

thomas
Posts: 7716
Nutzer

In deiner .ct-Datei ist ein Fehler: die Version-Zeile muß

##version $VER: loc 1.0 (28.08.2002)

lauten.

Außerdem nutzt du nicht die Möglichkeiten, die CatComp dir bietet.

Hier sind die korrigierten/vereinfachten Versionen:

loc.c:
code:
#include <clib/exec_protos.h>
#include <clib/locale_protos.h>

#include <stdio.h>

#define CATCOMP_NUMBERS
#define CATCOMP_STRINGS
#include "loc_catalog.h"

struct Catalog *mycatalog = NULL;

int main (void)
{
	mycatalog = OpenCatalog(NULL,"loc.catalog",TAG_END);

	printf((char *)GetCatalogStr(mycatalog, MSG_LANGUAGE, MSG_LANGUAGE_STR));

	CloseCatalog(mycatalog);

	return (0);
}


Anmerkungen:
- wenn du auto.lib dazulinkst, brauchst du die Libraries nicht zu öffnen (macht Dice C automatisch).
- wenn du xyz_protos.h einbindest, brauchst du die entsprechenen libraryies/xyz nicht mit einzubinden, die kommen automatisch mit dazu.

loc.ct:
code:
##version $VER: loc 1.0 (28.08.2002)
##codeset 0
##language deutsch
;
MSG_LANGUAGE
Die verwendete Systemsprache ist Deutsch.n
;
MSG_TEXT
Dieser Text ist in Ihrer Sprache.n
;
MSG_END
Tschüß!n
;


makefile:
code:
catalogs/deutsch/loc.catalog: catalogs/loc.cd catalogs/deutsch/loc.ct
	catcomp catalogs/loc.cd translation catalogs/deutsch/loc.ct catalog catalogs/deutsch/loc.catalog
	avail flush

loc_catalog.h: catalogs/loc.cd
	catcomp catalogs/loc.cd cfile loc_catalog.h noarray noblock nocode

loc: loc.c loc_catalog.h catalogs/deutsch/loc.catalog
	dcc loc.c -o loc


Gruß Thomas

--
Email: thomas-rapp@web.de

Home: home.t-online.de/home/thomas-rapp/


[ - Antworten - Zitieren - Direktlink - ]

29.08.2002, 10:22 Uhr

Micha1701
Posts: 938
Nutzer
Danke!

Es klappt!

--
:boing: Micha :boing:

Look at my HP: http://www.lanser-online.de.vu



[ - Antworten - Zitieren - Direktlink - ]


-1- [ - Beitrag schreiben - ]


amiga-news.de Forum > Programmierung > Probs mit LOCALE [ - Suche - Neue Beiträge - Registrieren - Login - ]


.
Impressum | Datenschutzerklärung | Netiquette | Werbung | Kontakt
Copyright © 1998-2024 by amiga-news.de - alle Rechte vorbehalten.
.