summaryrefslogtreecommitdiff
path: root/zen/i18n.h
diff options
context:
space:
mode:
authorDaniel Wilhelm <shieldwed@outlook.com>2017-04-20 16:55:28 -0600
committerDaniel Wilhelm <shieldwed@outlook.com>2017-04-20 16:59:56 -0600
commit823740e1ffa2b3bd39f8dea8062f5c5a0d9c741b (patch)
tree63222010af3b90a36f29c1c9c360116973cdff38 /zen/i18n.h
parentadd .gitattributes for less line ending hassles (diff)
downloadFreeFileSync-823740e1ffa2b3bd39f8dea8062f5c5a0d9c741b.tar.gz
FreeFileSync-823740e1ffa2b3bd39f8dea8062f5c5a0d9c741b.tar.bz2
FreeFileSync-823740e1ffa2b3bd39f8dea8062f5c5a0d9c741b.zip
normalize most lineendings
Diffstat (limited to 'zen/i18n.h')
-rwxr-xr-xzen/i18n.h238
1 files changed, 119 insertions, 119 deletions
diff --git a/zen/i18n.h b/zen/i18n.h
index ef3f3706..c7d1d5dc 100755
--- a/zen/i18n.h
+++ b/zen/i18n.h
@@ -1,119 +1,119 @@
-// *****************************************************************************
-// * This file is part of the FreeFileSync project. It is distributed under *
-// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 *
-// * Copyright (C) Zenju (zenju AT freefilesync DOT org) - All Rights Reserved *
-// *****************************************************************************
-
-#ifndef I18_N_H_3843489325044253425456
-#define I18_N_H_3843489325044253425456
-
-#include <string>
-#include <cstdint>
-#include "globals.h"
-#include "string_tools.h"
-#include "format_unit.h"
-
-//minimal layer enabling text translation - without platform/library dependencies!
-
-#define ZEN_TRANS_CONCAT_SUB(X, Y) X ## Y
-#define _(s) zen::implementation::translate(ZEN_TRANS_CONCAT_SUB(L, s))
-#define _P(s, p, n) zen::implementation::translate(ZEN_TRANS_CONCAT_SUB(L, s), ZEN_TRANS_CONCAT_SUB(L, p), n)
-//source and translation are required to use %x as number placeholder
-//for plural form, which will be substituted automatically!!!
-
-namespace zen
-{
-//implement handler to enable program-wide localizations:
-struct TranslationHandler
-{
- //THREAD-SAFETY: "const" member must model thread-safe access!
- TranslationHandler() {}
- virtual ~TranslationHandler() {}
-
- //C++11: std::wstring should be thread-safe like an int
- virtual std::wstring translate(const std::wstring& text) const = 0; //simple translation
- virtual std::wstring translate(const std::wstring& singular, const std::wstring& plural, int64_t n) const = 0;
-
-private:
- TranslationHandler (const TranslationHandler&) = delete;
- TranslationHandler& operator=(const TranslationHandler&) = delete;
-};
-
-void setTranslator(std::unique_ptr<const TranslationHandler>&& newHandler); //take ownership
-std::shared_ptr<const TranslationHandler> getTranslator();
-
-
-
-
-
-
-
-
-
-
-
-
-
-//######################## implementation ##############################
-namespace implementation
-{
-inline
-std::wstring translate(const std::wstring& text)
-{
- if (std::shared_ptr<const TranslationHandler> t = getTranslator()) //std::shared_ptr => temporarily take (shared) ownership while using the interface!
- return t->translate(text);
- return text;
-}
-
-
-//translate plural forms: "%x day" "%x days"
-//returns "1 day" if n == 1; "123 days" if n == 123 for english language
-inline
-std::wstring translate(const std::wstring& singular, const std::wstring& plural, int64_t n)
-{
- assert(contains(plural, L"%x"));
-
- if (std::shared_ptr<const TranslationHandler> t = getTranslator())
- {
- std::wstring translation = t->translate(singular, plural, n);
- assert(!contains(translation, L"%x"));
- return translation;
- }
-
- return replaceCpy(std::abs(n) == 1 ? singular : plural, L"%x", toGuiString(n));
-}
-
-
-template <class T> inline
-std::wstring translate(const std::wstring& singular, const std::wstring& plural, T n)
-{
- static_assert(sizeof(n) <= sizeof(int64_t), "");
- return translate(singular, plural, static_cast<int64_t>(n));
-}
-
-
-inline
-Global<const TranslationHandler>& refGlobalTranslationHandler()
-{
- //getTranslator() may be called even after static objects of this translation unit are destroyed!
- static Global<const TranslationHandler> inst; //external linkage even in header!
- return inst;
-}
-}
-
-
-inline
-void setTranslator(std::unique_ptr<const TranslationHandler>&& newHandler)
-{
- implementation::refGlobalTranslationHandler().set(std::move(newHandler));
-}
-
-
-inline
-std::shared_ptr<const TranslationHandler> getTranslator()
-{
- return implementation::refGlobalTranslationHandler().get();
-}
-}
-
-#endif //I18_N_H_3843489325044253425456
+// *****************************************************************************
+// * This file is part of the FreeFileSync project. It is distributed under *
+// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 *
+// * Copyright (C) Zenju (zenju AT freefilesync DOT org) - All Rights Reserved *
+// *****************************************************************************
+
+#ifndef I18_N_H_3843489325044253425456
+#define I18_N_H_3843489325044253425456
+
+#include <string>
+#include <cstdint>
+#include "globals.h"
+#include "string_tools.h"
+#include "format_unit.h"
+
+//minimal layer enabling text translation - without platform/library dependencies!
+
+#define ZEN_TRANS_CONCAT_SUB(X, Y) X ## Y
+#define _(s) zen::implementation::translate(ZEN_TRANS_CONCAT_SUB(L, s))
+#define _P(s, p, n) zen::implementation::translate(ZEN_TRANS_CONCAT_SUB(L, s), ZEN_TRANS_CONCAT_SUB(L, p), n)
+//source and translation are required to use %x as number placeholder
+//for plural form, which will be substituted automatically!!!
+
+namespace zen
+{
+//implement handler to enable program-wide localizations:
+struct TranslationHandler
+{
+ //THREAD-SAFETY: "const" member must model thread-safe access!
+ TranslationHandler() {}
+ virtual ~TranslationHandler() {}
+
+ //C++11: std::wstring should be thread-safe like an int
+ virtual std::wstring translate(const std::wstring& text) const = 0; //simple translation
+ virtual std::wstring translate(const std::wstring& singular, const std::wstring& plural, int64_t n) const = 0;
+
+private:
+ TranslationHandler (const TranslationHandler&) = delete;
+ TranslationHandler& operator=(const TranslationHandler&) = delete;
+};
+
+void setTranslator(std::unique_ptr<const TranslationHandler>&& newHandler); //take ownership
+std::shared_ptr<const TranslationHandler> getTranslator();
+
+
+
+
+
+
+
+
+
+
+
+
+
+//######################## implementation ##############################
+namespace implementation
+{
+inline
+std::wstring translate(const std::wstring& text)
+{
+ if (std::shared_ptr<const TranslationHandler> t = getTranslator()) //std::shared_ptr => temporarily take (shared) ownership while using the interface!
+ return t->translate(text);
+ return text;
+}
+
+
+//translate plural forms: "%x day" "%x days"
+//returns "1 day" if n == 1; "123 days" if n == 123 for english language
+inline
+std::wstring translate(const std::wstring& singular, const std::wstring& plural, int64_t n)
+{
+ assert(contains(plural, L"%x"));
+
+ if (std::shared_ptr<const TranslationHandler> t = getTranslator())
+ {
+ std::wstring translation = t->translate(singular, plural, n);
+ assert(!contains(translation, L"%x"));
+ return translation;
+ }
+
+ return replaceCpy(std::abs(n) == 1 ? singular : plural, L"%x", toGuiString(n));
+}
+
+
+template <class T> inline
+std::wstring translate(const std::wstring& singular, const std::wstring& plural, T n)
+{
+ static_assert(sizeof(n) <= sizeof(int64_t), "");
+ return translate(singular, plural, static_cast<int64_t>(n));
+}
+
+
+inline
+Global<const TranslationHandler>& refGlobalTranslationHandler()
+{
+ //getTranslator() may be called even after static objects of this translation unit are destroyed!
+ static Global<const TranslationHandler> inst; //external linkage even in header!
+ return inst;
+}
+}
+
+
+inline
+void setTranslator(std::unique_ptr<const TranslationHandler>&& newHandler)
+{
+ implementation::refGlobalTranslationHandler().set(std::move(newHandler));
+}
+
+
+inline
+std::shared_ptr<const TranslationHandler> getTranslator()
+{
+ return implementation::refGlobalTranslationHandler().get();
+}
+}
+
+#endif //I18_N_H_3843489325044253425456
bgstack15