Skip to content

armgit / WacOS

Public Imported from GitHub
0

A new style desktop shell for Windows 11: menu bar, Dock, Finder, Spotlight, Control Center and Liquid Glass, in native C++.

Rust

Activity Monitor: numbers in the WacOS language's format, translatable Kind

Eternity070628697945c84f86
diff --git a/src/monitor/main.cpp b/src/monitor/main.cpp
index dbf3d64..0431a81 100644
--- a/src/monitor/main.cpp
+++ b/src/monitor/main.cpp
@@ -213,7 +213,7 @@ void Identify(Proc& p) {
USHORT pm = 0, nm = 0;
if (IsWow64Process2(h, &pm, &nm)) {
USHORT m = pm == IMAGE_FILE_MACHINE_UNKNOWN ? nm : pm;
- p.kind = m == IMAGE_FILE_MACHINE_AMD64 ? L"64 bits" : m == IMAGE_FILE_MACHINE_ARM64 ? L"ARM64" : m == IMAGE_FILE_MACHINE_I386 ? L"32 bits" : L"—";
+ p.kind = m == IMAGE_FILE_MACHINE_AMD64 ? Tr(L"64 bits") : m == IMAGE_FILE_MACHINE_ARM64 ? L"ARM64" : m == IMAGE_FILE_MACHINE_I386 ? Tr(L"32 bits") : L"—";
}
HANDLE tok = nullptr;
if (OpenProcessToken(h, TOKEN_QUERY, &tok)) {
@@ -228,7 +228,7 @@ void Identify(Proc& p) {
CloseHandle(h);
}
if (p.user.empty()) p.user = p.session == 0 ? L"SYSTEM" : g_me;
- if (p.kind.empty()) p.kind = L"64 bits"; // protegidos do sistema: sempre nativos
+ if (p.kind.empty()) p.kind = Tr(L"64 bits"); // protegidos do sistema: sempre nativos
// apps (fora da pasta do Windows): nome do app e ícone; serviços do sistema: o nome do executável, como no Mac
std::wstring base = p.exe;
if (base.size() > 4 && !_wcsicmp(base.c_str() + base.size() - 4, L".exe")) base.resize(base.size() - 4);
@@ -483,13 +483,33 @@ void Sample() {
// ---------------------------------------------------------------------------
// Textos (pt-BR, unidades decimais como no Mac)
+// Separadores do idioma do WacOS, pelo Windows (GetLocaleInfoEx com idioma::Locale()): "1,234.5" em inglês, chinês,
+// japonês e coreano, "1.234,5" em português, espanhol, alemão, italiano e turco, "1 234,5" em francês, russo e
+// polonês. Antes eram sempre os do português, em qualquer idioma.
+const std::wstring& Separador(bool decimal) {
+ static std::wstring dec, mil;
+ if (dec.empty()) {
+ wchar_t b[8] = {};
+ dec = GetLocaleInfoEx(idioma::Locale(), LOCALE_SDECIMAL, b, 8) > 1 ? b : (idioma::DecimalComma() ? L"," : L".");
+ b[0] = 0;
+ mil = GetLocaleInfoEx(idioma::Locale(), LOCALE_STHOUSAND, b, 8) > 1 ? b : (idioma::DecimalComma() ? L"." : L",");
+ }
+ return decimal ? dec : mil;
+}
std::wstring Thousands(ULONGLONG v) {
std::wstring s = std::to_wstring(v), o;
+ const std::wstring& mil = Separador(false);
int n = 0;
- for (int i = (int)s.size() - 1; i >= 0; i--) { o.insert(o.begin(), s[i]); if (++n % 3 == 0 && i > 0) o.insert(o.begin(), L'.'); }
+ for (int i = (int)s.size() - 1; i >= 0; i--) { o.insert(o.begin(), s[i]); if (++n % 3 == 0 && i > 0) o.insert(0, mil); }
+ return o;
+}
+// "12.5" (swprintf) -> com o separador decimal do idioma
+std::wstring Comma(std::wstring s) {
+ const std::wstring& dec = Separador(true);
+ std::wstring o;
+ for (wchar_t c : s) { if (c == L'.') o += dec; else o += c; }
return o;
}
-std::wstring Comma(std::wstring s) { for (auto& c : s) if (c == L'.') c = L','; return s; }
std::wstring Bytes(double b) {
wchar_t buf[48];
if (b < 1000) swprintf_s(buf, Tr(L"%.0f bytes"), b);
@@ -503,9 +523,9 @@ std::wstring Pct(double v) { wchar_t b[32]; swprintf_s(b, L"%.1f", v); return Co
std::wstring CpuTime(ULONGLONG t100ns) {
ULONGLONG cs = t100ns / 100000, s = cs / 100, h = s / 3600, m = (s / 60) % 60; s %= 60; cs %= 100;
wchar_t b[48];
- if (h) swprintf_s(b, L"%llu:%02llu:%02llu,%02llu", h, m, s, cs);
- else swprintf_s(b, L"%llu:%02llu,%02llu", m, s, cs);
- return b;
+ if (h) swprintf_s(b, L"%llu:%02llu:%02llu.%02llu", h, m, s, cs);
+ else swprintf_s(b, L"%llu:%02llu.%02llu", m, s, cs);
+ return Comma(b); // os centésimos com o separador decimal do idioma
}
// ---------------------------------------------------------------------------