Verba.Translations
2.2.0
dotnet add package Verba.Translations --version 2.2.0
NuGet\Install-Package Verba.Translations -Version 2.2.0
<PackageReference Include="Verba.Translations" Version="2.2.0" />
<PackageVersion Include="Verba.Translations" Version="2.2.0" />
<PackageReference Include="Verba.Translations" />
paket add Verba.Translations --version 2.2.0
#r "nuget: Verba.Translations, 2.2.0"
#:package Verba.Translations@2.2.0
#addin nuget:?package=Verba.Translations&version=2.2.0
#tool nuget:?package=Verba.Translations&version=2.2.0
Verba — client .NET (Verba.Translations)
Un singur pachet, două roluri:
- build — la fiecare
dotnet buildurcă cheile noi (cu token write) și aduce traducerile din Verba în fișierele de resurse (.resxsau.json). Fără tool global, fără PATH, fără target propriu în.csproj; - runtime (OTA, opțional) — textele modificate în Verba apar în aplicația care rulează, fără redeploy.
Integrare
dotnet add package Verba.Translations
verba.json lângă .csproj (se comite):
{ "project": "slug-proiect" }
Tokenuri, căutate în ordine (fișierele și appsettings lângă verba.json, sau appsettings din
<VerbaAppSettingsDir>../Host</VerbaAppSettingsDir> pentru o bibliotecă de UI al cărei host are appsettings-ul):
| env | fișier (gitignored) | appsettings(.Development).json | |
|---|---|---|---|
| read (fetch) | VERBA_TOKEN |
.verba-token |
"Verba": { "Token": "…" } |
| write (push) | VERBA_WRITE_TOKEN |
.verba-write-token |
"Verba": { "WriteToken": "…" } |
Push (cod → Verba)
Cu token write, fiecare build face întâi push, apoi fetch: cheile care există doar în fișiere se creează în Verba cu textele lor, valorile goale din Verba se completează. Ce e deja în Verba nu se suprascrie (Verba e sursa de adevăr), iar cheile șterse în Verba nu reînvie. Fără token write, fetch-ul rescrie fișierele cu ce e în Verba — o cheie adăugată doar local se pierde.
- doar push, fără build:
dotnet build -t:VerbaPush - fetch fără push automat:
-p:VerbaAutoPush=false - acoladele: un text fără
{0}e trimis cu acoladele dublate ({AAAA}→{{AAAA}}), ca la export să iasă identic.
Ce se deduce
| Câmp | Implicit |
|---|---|
locales |
din Verba (/manifest, după token) |
outDir |
Resources (relativ la verba.json) |
format |
dotnet-resx dacă în outDir există deja un .resx neutru, altfel dotnet-json |
baseName |
numele acelui .resx (Localization.resx → Localization), altfel Strings |
neutralLocale |
(resx) limba fără {baseName}.{limbă}.resx, altfel limba implicită din Verba |
Fișiere: {baseName}.{limbă}.{ext}; limba neutră → {baseName}.resx. Un fișier se rescrie doar dacă
s-a schimbat. Orice câmp se poate fixa explicit (plus server pentru self-host).
Fail-soft: fără token / offline / eroare → avertisment, build-ul continuă cu fișierele existente.
Oprire: dotnet build -p:VerbaFetchEnabled=false. Alt config: -p:VerbaConfig=cale/verba.json.
Acoladele literale se scriu dublat în Verba (MD-CPE-{{AAAA}}); altfel sunt placeholder-e.
OTA la runtime (opțional)
builder.Services.AddVerbaOta(builder.Configuration.GetSection("Verba")); // "Verba": { "Token": "<read>" }
În căutarea textelor, Verba întâi, apoi resursa compilată:
VerbaOta.Get(key, culture) ?? ResourceManager.GetString(key, culture) ?? key
- fără rețea pe calea de randare: dicționar în memorie, înlocuit atomic de un
BackgroundService; - la fiecare
OtaInterval(implicit 1 min) câte o cerere condiționată per limbă — fără schimbări →304; - Verba indisponibil → rămân ultimele texte bune (la pornire: resursele compilate), o singură avertizare;
- opțional în secțiune:
Project,Locales(implicit din token),Server,OtaInterval,OtaEnabled; VerbaOta.Updated— eveniment după aplicarea unui set nou.
Istoric
- 2.2.0 — OTA la runtime în același pachet (
VerbaOta,AddVerbaOta). - 2.1.0 — push (automat cu token write, sau
-t:VerbaPush);Verba:WriteToken. - 2.0.0 — pachet MSBuild (până la 1.x: dotnet tool global
verba-fetch).
Dezvoltare în repo
Pachetul se face din VerbaRuntime/ (bibliotecă + build/), cu VerbaFetch/ în tools/.
Verba.targets rulează VerbaFetch din sursă (dotnet run), pentru test fără pachet:
<Import Project="/cale/către/Verba/clients/dotnet/Verba.targets" />
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.