17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-20 17:24:53 +02:00
Files
maszyna/utilities/translation.h
maj00r d25f20a56c feat(track): 3D sleepers and switch timbers, blade heel and throw from templates, one rail carving pass
- sleepers3d / sleepers3dplain / sleepers3dbed in eu07.ini: timbers put together from the begin, main and end parts of a model
  and stretched to their length, plain sleepers of their own model; tracks whose plain sleepers would touch are laid as one
  cluster, lines of timbers led by priority and turned to the bisectors of frogs and crossings at a limited rate, whole timbers
  under crossings, split ones between tracks with room to part them, gaps filled per rail and overlaps shortened or dropped;
  clusters worked out in a background thread while driving, on demand in the editor
- the ballast can be left out under the beams (sleepers3dbed no)
- blades get their heel and throw from the switch template or blades <heel> <throw> in the scenery; blades of double switches
  run on into the track linking them to the next switch
- rail cutting at frogs, wing rails, movable noses and switch crossings done by one carving pass (RailCarve)
- tint of the rail treads applied to the colour only, without the matte band at the frog
- a switch trailed through with a movable nose set the other way derails the vehicle
- self-tests: sleepercheck, sharedzones, beamsnear, throw, sleepersbg
2026-10-17 23:32:43 +02:00

45 lines
1.4 KiB
C++

/*
This Source Code Form is subject to the
terms of the Mozilla Public License, v.
2.0. If a copy of the MPL was not
distributed with this file, You can
obtain one at
http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <string>
#include <unordered_map>
#include <vector>
class locale {
public:
void init();
std::string label_cab_control(const std::string &Label);
const std::string &coupling_name(int c);
const char* lookup_c(const char *msg, bool constant = false);
const std::string& lookup_s(const std::string &msg, bool constant = false);
const char* lookup_n(const char *singular, const char *plural, long long n);
private:
bool parse_translation(std::istream &stream);
std::string parse_c_literal(const std::string &str);
std::size_t plural_form(long long n) const;
std::unordered_map<std::string, std::string> lang_mapping;
std::unordered_map<const void*, const void*> pointer_cache;
std::unordered_map<std::string, std::vector<std::string>> plural_mapping;
std::unordered_map<const void*, const std::vector<std::string>*> plural_cache;
};
extern locale Translations;
#define STR(x) Translations.lookup_s(x, false)
#define STR_C(x) Translations.lookup_c(x, true)
#define STRN(x) x
#define STR_P(singular, plural, n) Translations.lookup_n(singular, plural, n)
//find . -name "*.cpp" | xargs xgettext --from-code="UTF-8" -k --keyword=STR --keyword=STR_C --keyword=STRN --keyword=STR_P:1,2