Fix localedir relocation.

Since LOCALEDIR is now always absolute we need to see if there's a
prefix and if LOCALEDIR is a subdir of PREFIX instead.
This commit is contained in:
John Ralls
2018-09-18 16:08:48 -07:00
parent 59a6ebc33a
commit 2d565215cd

View File

@@ -24,6 +24,7 @@
#include "gncla-dir.h"
#include <stdio.h>
#include "binreloc.h"
#include "gnc-filepath-utils.h"
gchar *gnc_path_get_prefix()
{
@@ -138,13 +139,19 @@ gchar *gnc_path_get_gtkbuilderdir()
* @returns A newly allocated string. */
gchar *gnc_path_get_localedir()
{
if (g_path_is_absolute (LOCALEDIR))
return g_strdup(LOCALEDIR);
gchar *prefix = gnc_path_get_prefix();
char *locale_subdir = gnc_file_path_relative_part (PREFIX, LOCALEDIR);
if (prefix == NULL || g_strcmp0 (locale_subdir, LOCALEDIR) == 0)
{
g_free (prefix);
g_free (locale_subdir);
return LOCALEDIR;
}
else
{
gchar *prefix = gnc_path_get_prefix();
gchar *result = g_build_filename (prefix, LOCALEDIR, (char*)NULL);
gchar *result = g_build_filename (prefix, locale_subdir, (char*)NULL);
g_free (prefix);
g_free (locale_subdir);
//printf("Returning localedir %s\n", result);
return result;
}