pool->languages[i] = strdup(languages[i]);
}
+Id
+pool_id2langid(Pool *pool, Id id, const char *lang, int create)
+{
+ const char *n;
+ char buf[256], *p;
+ int l;
+
+ if (!lang)
+ return id;
+ n = id2str(pool, id);
+ l = strlen(n) + strlen(lang) + 2;
+ if (l > sizeof(buf))
+ p = sat_malloc(strlen(n) + strlen(lang) + 2);
+ else
+ p = buf;
+ sprintf(p, "%s:%s", n, lang);
+ id = str2id(pool, p, create);
+ if (p != buf)
+ free(p);
+ return id;
+}
+
char *
pool_alloctmpspace(Pool *pool, int len)
{
extern const char *solvable2str(Pool *pool, Solvable *s);
void pool_set_languages(Pool *pool, const char **languages, int nlanguages);
+Id pool_id2langid(Pool *pool, Id id, const char *lang, int create);
Id solvable_lookup_id(Solvable *s, Id keyname);
unsigned int solvable_lookup_num(Solvable *s, Id keyname, unsigned int notfound);
const char *
solvable_lookup_str_lang(Solvable *s, Id keyname, const char *lang)
{
- Pool *pool;
- Id id;
- char *p;
- const char *kn, *str;
-
- if (!s->repo)
- return repo_lookup_str(s, keyname);
- pool = s->repo->pool;
- kn = id2str(pool, keyname);
- p = sat_malloc(strlen(kn) + strlen(lang) + 2);
- sprintf(p, "%s:%s", kn, lang);
- id = str2id(pool, p, 0);
- free(p);
- if (id)
+ if (s->repo)
{
- str = repo_lookup_str(s, id);
- if (str)
- return str;
+ const char *str;
+ Id id = pool_id2langid(s->repo->pool, keyname, lang, 0);
+ if (id && (str = repo_lookup_str(s, id)) != 0)
+ return str;
}
return repo_lookup_str(s, keyname);
}