File: intl.c

package info (click to toggle)
dia 0.97.3%2Bgit20160930-9
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 54,372 kB
  • sloc: ansic: 155,065; xml: 16,326; python: 6,641; cpp: 4,935; makefile: 3,833; sh: 540; perl: 137; sed: 19
file content (30 lines) | stat: -rw-r--r-- 518 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <config.h>

#include "intl.h"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/* low numbers are better */
int
intl_score_locale(const gchar *locale)
{
  const gchar * const *names = g_get_language_names ();
  int i = 0;

  /* NULL is same as C locale */
  if (!locale) {
    while (names[i] != NULL)
      ++i;
    return i;
  }
  while (names[i] != NULL) {
    if (strcmp(names[i], locale) == 0)
      break;
    ++i;
  }
  if (names[i] == NULL) /* not found */
    i = G_MAXINT;
  return i;
}