/* International.c generated by valac 0.56.19, the Vala compiler
 * generated from International.vala, do not modify */

/* Copyright 2016 Software Freedom Conservancy Inc.
 *
 * This software is licensed under the GNU LGPL (version 2.1 or later).
 * See the COPYING file in this distribution.
 */

#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <config.h>
#include <locale.h>
#include <glib/gi18n-lib.h>
#include <gio/gio.h>

#define TRANSLATABLE "translatable"
#define INTERNATIONAL_SUPPORT_SYSTEM_LOCALE ""
#define INTERNATIONAL_SUPPORT_LANGUAGE_SUPPORT_DIRECTORY _LANG_SUPPORT_DIR
#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

VALA_EXTERN void international_support_init (const gchar* package_name,
                                 gchar** args,
                                 gint args_length1,
                                 const gchar* locale);
VALA_EXTERN gchar* international_support_get_langpack_dir_path (gchar** args,
                                                    gint args_length1);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

void
international_support_init (const gchar* package_name,
                            gchar** args,
                            gint args_length1,
                            const gchar* locale)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	g_return_if_fail (package_name != NULL);
	g_return_if_fail (locale != NULL);
	setlocale (LC_ALL, locale);
	_tmp0_ = international_support_get_langpack_dir_path (args, (gint) args_length1);
	_tmp1_ = _tmp0_;
	bindtextdomain (package_name, _tmp1_);
	_g_free0 (_tmp1_);
	bind_textdomain_codeset (package_name, "UTF-8");
	textdomain (package_name);
}

gchar*
international_support_get_langpack_dir_path (gchar** args,
                                             gint args_length1)
{
	GFile* local_langpack_dir = NULL;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	GFile* _tmp3_;
	GFile* _tmp4_;
	GFile* _tmp5_;
	GFile* _tmp6_;
	GFile* _tmp7_;
	GFile* _tmp8_;
	GFile* _tmp9_;
	GFile* _tmp10_;
	gchar* _tmp11_ = NULL;
	GFile* _tmp12_;
	gchar* _tmp16_;
	gchar* result;
	_tmp0_ = args[0];
	_tmp1_ = g_find_program_in_path (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_file_new_for_path (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = g_file_get_parent (_tmp4_);
	_tmp6_ = _tmp5_;
	_tmp7_ = g_file_get_parent (_tmp6_);
	_tmp8_ = _tmp7_;
	_tmp9_ = g_file_get_child (_tmp8_, "locale-langpack");
	_tmp10_ = _tmp9_;
	_g_object_unref0 (_tmp8_);
	_g_object_unref0 (_tmp6_);
	_g_object_unref0 (_tmp4_);
	_g_free0 (_tmp2_);
	local_langpack_dir = _tmp10_;
	_tmp12_ = local_langpack_dir;
	if (g_file_query_exists (_tmp12_, NULL)) {
		GFile* _tmp13_;
		gchar* _tmp14_;
		_tmp13_ = local_langpack_dir;
		_tmp14_ = g_file_get_path (_tmp13_);
		_g_free0 (_tmp11_);
		_tmp11_ = _tmp14_;
	} else {
		gchar* _tmp15_;
		_tmp15_ = g_strdup (INTERNATIONAL_SUPPORT_LANGUAGE_SUPPORT_DIRECTORY);
		_g_free0 (_tmp11_);
		_tmp11_ = _tmp15_;
	}
	_tmp16_ = _tmp11_;
	_tmp11_ = NULL;
	result = _tmp16_;
	_g_free0 (_tmp11_);
	_g_object_unref0 (local_langpack_dir);
	return result;
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

