• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ParadoxGameConverters / Vic3ToHoI4 / 15810584879

22 Jun 2025 08:38PM UTC coverage: 94.151%. First build
15810584879

Pull #730

github

web-flow
Merge dc11e5c47 into aceb64594
Pull Request #730: Update commons and simplify

315 of 316 new or added lines in 40 files covered. (99.68%)

21826 of 23182 relevant lines covered (94.15%)

57153.31 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.0
/src/out_hoi4/localizations/out_localizations.cpp
1
#include "src/out_hoi4/localizations/out_localizations.h"
2

3
#include <external/commonItems/CommonFunctions.h>
4
#include <external/commonItems/OSCompatibilityLayer.h>
5
#include <external/fmt/include/fmt/format.h>
6

7
#include <array>
8
#include <fstream>
9

10

11

12
using std::filesystem::path;
13

14

15

16
namespace
17
{
18

19
constexpr std::array supported_languages =
20
    {"braz_por", "english", "french", "german", "japanese", "polish", "russian", "spanish", "simp_chinese"};
21

22

23
void CreateFolders(const path& output_name)
21✔
24
{
25
   const path localisations_path = "output" / output_name / "localisation";
21✔
26
   if (!commonItems::DoesFolderExist(localisations_path) && !create_directories(localisations_path))
21✔
27
   {
28
      throw std::runtime_error(fmt::format("Could not create {}", localisations_path.string()));
×
29
   }
30

31
   for (const auto& language: supported_languages)
210✔
32
   {
33
      if (const path language_path = localisations_path / language;
189✔
34
          !commonItems::DoesFolderExist(language_path) && !create_directories(language_path))
189✔
35
      {
36
         throw std::runtime_error(fmt::format("Could not create {}", language_path.string()));
×
37
      }
189✔
38
   }
39
}
21✔
40

41

42
void OutputLocalisations(const path& output_name,
105✔
43
    std::string_view localization_file,
44
    const commonItems::LocalizationDatabase& localization_database)
45
{
46
   for (const auto& language: supported_languages)
1,050✔
47
   {
48
      const path localization_path(
49
          "output" / output_name / fmt::format("localisation/{}/{}{}.yml", language, localization_file, language));
945✔
50
      std::ofstream file(localization_path);
945✔
51
      if (!file.is_open())
945✔
52
      {
NEW
53
         throw std::runtime_error(localization_path.string());
×
54
      }
55
      file << fmt::format("{}l_{}:\n", commonItems::utf8BOM, language);
945✔
56

57
      for (const auto& [key, localization_block]: localization_database)
1,116✔
58
      {
59
         file << fmt::format(" {}:0 \"{}\"\n", key, localization_block.GetLocalization(language));
171✔
60
      }
61

62
      file.close();
945✔
63
   }
945✔
64
}
105✔
65

66
}  // namespace
67

68

69

70
void out::OutputLocalizations(const path& output_name, const hoi4::Localizations& localizations)
21✔
71
{
72
   CreateFolders(output_name);
21✔
73
   OutputLocalisations(output_name, "countries_l_", localizations.GetCountryLocalizations());
21✔
74
   OutputLocalisations(output_name, "state_names_l_", localizations.GetStateLocalizations());
21✔
75
   OutputLocalisations(output_name, "victory_points_l_", localizations.GetVictoryPointLocalizations());
21✔
76
   OutputLocalisations(output_name, "character_names_l_", localizations.GetCharacterLocalizations());
21✔
77
   OutputLocalisations(output_name, "converter_ideas_l_", localizations.GetIdeaLocalizations());
21✔
78
}
21✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc