NAME
ort_lang_xliff_join —
merge configuration and
translation
LIBRARY
library “libort-lang-xliff”
SYNOPSIS
#include
<sys/queue.h>
#include <stdio.h>
#include <ort.h>
#include
<ort-lang-xliff.h>
int
ort_lang_xliff_join(const struct
ort_lang_xliff *args, struct config *cfg,
FILE *f, struct msgq *mq);
DESCRIPTION
Outputs a ort(5)
configuration to f consisting of
cfg merged with translations given in
args. Errors and warnings are enqueued to
mq, if not NULL. The arguments
recgnised in args are as follows:
- unsigned int flags
- If the
ORT_LANG_XLIFF_COPYmask is set and a translation is not provided for a given label, use the default label instead of erroring out. - FILE **in
- XLIFF 1.2 input files consisting of translations.
- const char *const *fnames
- The filenames (for informational purposes only) of files in in.
- size_t insz
- The number of elements in in and fnames.
ort_lang_xliff_join alters cfg
in-place by adding translations.
RETURN VALUES
Returns one of the following values:
EXAMPLES
A simple scenario of creating a configuration, parsing standard input, linking, then joining with a translation file fr.xlf.
struct config *cfg;
struct ort_lang_xliff args;
struct msgq mq = TAILQ_HEAD_INITIALIZER(mq);
FILE *f;
const char *fname = "fr.xlf";
if ((f = fopen(fname, "r")) == NULL)
err(1, "%s", fname);
memset(&args, 0, sizeof(struct ort_lang_xliff));
args.in = &f;
args.fnames = &fname;
args.insz = 1;
if ((cfg = ort_config_alloc()) == NULL)
err(1, NULL);
if (ort_parse_file(cfg, stdin, "<stdin>") &&
ort_parse_close(cfg) &&
ort_lang_xliff_join(&args, cfg, stdout, &mq) > 0)
ort_write_file(stdout, cfg);
ort_write_msg_file(stderr, &cfg.mq);
ort_write_msg_file(stderr, &mq);
ort_config_free(cfg);
ort_msgq_free(&mq);