2 * nls.c : Helpers for NLS programs.
4 * ====================================================================
5 * Licensed to the Apache Software Foundation (ASF) under one
6 * or more contributor license agreements. See the NOTICE file
7 * distributed with this work for additional information
8 * regarding copyright ownership. The ASF licenses this file
9 * to you under the Apache License, Version 2.0 (the
10 * "License"); you may not use this file except in compliance
11 * with the License. You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing,
16 * software distributed under the License is distributed on an
17 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 * KIND, either express or implied. See the License for the
19 * specific language governing permissions and limitations
21 * ====================================================================
27 #include <sys/types.h>
33 #include <apr_errno.h>
36 #include "svn_error.h"
37 #include "svn_pools.h"
40 #include "private/svn_utf_private.h"
42 #include "svn_private_config.h"
47 svn_error_t *err = SVN_NO_ERROR;
50 if (getenv("SVN_LOCALE_DIR"))
52 bindtextdomain(PACKAGE_NAME, getenv("SVN_LOCALE_DIR"));
57 WCHAR ucs2_path[MAX_PATH];
58 const char* utf8_path;
59 const char* internal_path;
60 apr_pool_t* scratch_pool;
62 scratch_pool = svn_pool_create(NULL);
63 /* get exe name - our locale info will be in '../share/locale' */
64 GetModuleFileNameW(NULL, ucs2_path,
65 sizeof(ucs2_path) / sizeof(ucs2_path[0]));
66 if (apr_get_os_error())
68 err = svn_error_wrap_apr(apr_get_os_error(),
69 _("Can't get module file name"));
73 err = svn_utf__win32_utf16_to_utf8(&utf8_path, ucs2_path,
78 internal_path = svn_dirent_internal_style(utf8_path, scratch_pool);
79 /* get base path name */
80 internal_path = svn_dirent_dirname(internal_path, scratch_pool);
81 internal_path = svn_dirent_join(internal_path,
82 SVN_LOCALE_RELATIVE_PATH,
84 SVN_ERR(svn_dirent_get_absolute(&internal_path, internal_path,
86 bindtextdomain(PACKAGE_NAME, internal_path);
89 svn_pool_destroy(scratch_pool);
92 bindtextdomain(PACKAGE_NAME, SVN_LOCALE_DIR);
96 #ifdef HAVE_BIND_TEXTDOMAIN_CODESET
97 bind_textdomain_codeset(PACKAGE_NAME, "UTF-8");
98 #endif /* HAVE_BIND_TEXTDOMAIN_CODESET */
100 #endif /* ENABLE_NLS */