All Projects → lukaskabrt → PoExtractor

lukaskabrt / PoExtractor

Licence: MIT license
Extracts localizable strings from .cs, .vb, .cshtml and .liquid files into POT files

Programming Languages

C#
18002 projects
Liquid
124 projects

Projects that are alternatives of or similar to PoExtractor

NALib
General purpose C sourcecode collection
Stars: ✭ 16 (-58.97%)
Mutual labels:  localization
PersianDataAnnotations
PersianDataAnnotations is ASP.NET Core MVC & ASP.NET MVC Custom Localization DataAnnotations (Localized MVC Errors) for Persian(Farsi) language - فارسی سازی خطاهای اعتبارسنجی توکار ام.وی.سی. و کور.ام.وی.سی. برای نمایش اعتبار سنجی سمت کلاینت
Stars: ✭ 38 (-2.56%)
Mutual labels:  localization
ai for robotics
Visualizations of algorithms covered in Sebastian Thrun's excellent Artificial Intelligence for Robotics course on Udacity.
Stars: ✭ 125 (+220.51%)
Mutual labels:  localization
turnwing
Type safe & hackable localization library for Haxe
Stars: ✭ 39 (+0%)
Mutual labels:  localization
alternate
Plug and Phoenix helpers to localize your web app via the URL
Stars: ✭ 26 (-33.33%)
Mutual labels:  localization
FortniteTracker
🔎 A tracker for the various Fortnite Files
Stars: ✭ 32 (-17.95%)
Mutual labels:  localization
sketch-crowdin
Connect your Sketch and Crowdin projects together
Stars: ✭ 35 (-10.26%)
Mutual labels:  localization
LocalizationUE4
Translation Editor for Unreal Engine 4
Stars: ✭ 59 (+51.28%)
Mutual labels:  localization
CHR
SIXray : A Large-scale Security Inspection X-ray Benchmark in CVPR 2019
Stars: ✭ 78 (+100%)
Mutual labels:  localization
XLocalizer
Localizer package for Asp.Net Core web applications, powered by online translation and auto resource creating.
Stars: ✭ 103 (+164.1%)
Mutual labels:  localization
glottos
A PHP 5.3+ Translation/Localization System
Stars: ✭ 70 (+79.49%)
Mutual labels:  localization
flutter localization example
A flutter localization example
Stars: ✭ 31 (-20.51%)
Mutual labels:  localization
wp-loco
MIRROR of the official Loco Wordpress plugin "Loco Translate"
Stars: ✭ 35 (-10.26%)
Mutual labels:  localization
docker-compose
Docker compose for Weblate
Stars: ✭ 62 (+58.97%)
Mutual labels:  localization
awesome-i18n
🌍 A curated list of i18n resources for all kind of languages and frameworks
Stars: ✭ 205 (+425.64%)
Mutual labels:  localization
fuse-device
Use the basic Device functions such as UUID and current localization from Fuse
Stars: ✭ 13 (-66.67%)
Mutual labels:  localization
ad localize
ADLocalize is a simple way to manage your localization files. Supported wording sources : CSVs and Google Sheets. Localization file generation available for iOS, Android, JSON (i18next), YAML and Java properties
Stars: ✭ 22 (-43.59%)
Mutual labels:  localization
slam gmapping
Slam Gmapping for ROS2
Stars: ✭ 56 (+43.59%)
Mutual labels:  localization
poeditor-cli
POEditor CLI
Stars: ✭ 29 (-25.64%)
Mutual labels:  localization
asgi-babel
Adds internationalization (i18n) support to ASGI applications (Asyncio/Trio)
Stars: ✭ 21 (-46.15%)
Mutual labels:  localization

OrchardCoreContrib.PoExtractor

OrchardCoreContrib.PoExtractor is distributed as a dotnet global tool to extracts translatable strings from the C# and VB code, Razor templates and Liquid templates to POT (portable object template) files. It is designed to follow conventions used in the OrchardCore project.

Installation

Install with the following command:

dotnet tool install --global OrchardCoreContrib.PoExtractor

Usage

dotnet extractpo <INTPUT_PATH> <OUTPUT_PATH> [-l|--language {"C#"|"VB"}] [-t|--template {"razor"|"liquid"}]

Description

Extracts all translatable strings from projects at the specified input path and saves generated POT files at the specified output path. It creates one POT file per a project. This includes liquid views.

Arguments

  • INTPUT_PATH

The path to the input directory, all projects at the the path will be processed.

  • OUTPUT_PATH

The path to a directory where POT files will be generated.

Options

  • -l|--language {C#|VB}

Specifies the code language to extracts translatable strings from. Default: C# language

  • -t|--template {"razor"|"liquid"}

Specifies the template engine to extract the translatable strings from. Default: Razor & Liquid templates.

Uninstallation

dotnet tool uninstall --global OrchardCoreContrib.PoExtractor

Limitations

OrchardCoreContrib.PoExtractor assumes, the code follows several conventions:

  • IStringLocalizer or a derived class is accessed via a field named S (This is a convention used in Orchard Core)
  • IHtmlLocalizer or a derived class is accessed via a field named H (This is a convention used in Orchard Core)
  • IStringLocalizer or IHtmlLocalizer is accessed via a field named T (This is a older convention used in Orchard Core)
  • Liquid templates use the filter named t (This is a convention used in Fluid)
  • context of the localizable string is the full name (with namespace) of the containing class for C# or VB code
  • context of the localizable string is the dot-delimited relative path the to view for Razor templates
  • context of the localizable string is the dot-delimited relative path the to template for Liquid templates

Example

C# code:

namespace OrchardCore.ContentFields.Fields { 
    public class LinkFieldDisplayDriver : ContentFieldDisplayDriver<LinkField> {
        private IStringLocalizer S;

        public LinkFieldDisplayDriver(IStringLocalizer<LinkFieldDisplayDriver> localizer) {
            S = localizer;
        }

        public override async Task<IDisplayResult> UpdateAsync(LinkField field, IUpdateModel updater, UpdateFieldEditorContext context) {
            bool modelUpdated = await updater.TryUpdateModelAsync(field, Prefix, f => f.Url, f => f.Text);

            if (modelUpdated)
            {
                var settings = context.PartFieldDefinition.Settings.ToObject<LinkFieldSettings>();

                if (settings.Required && String.IsNullOrWhiteSpace(field.Url))
                {
                    updater.ModelState.AddModelError(Prefix, S["The url is required for {0}.", context.PartFieldDefinition.DisplayName()]);
                }
            }

            return Edit(field, context);
        }
    }
}

VB code:

Namespace OrchardCore.Modules.GreetingModule 
    Public Class Greeting
        private readonly S As IStringLocalizer(Of Greeting)

        Public Sub New(ByVal localizer As IStringLocalizer(Of Greeting))
            S = localizer
        End Sub

        Public Sub Saulation(byVal name As String)
            Console.WriteLine(S("Hi {0} ...", name))
        End Sub
    End Class
End Namespace

Razor view:

@model OrchardCore.ContentFields.ViewModels.EditLinkFieldViewModel

<div class="row">
    <fieldset class="form-group col-md-12">
        <label asp-for="Url">@Model.PartFieldDefinition.DisplayName()</label>
    </fieldset>
    <fieldset class="form-group col-md-6" asp-validation-class-for="Url">
        <input asp-for="Url" class="form-control content-preview-text" placeholder="@settings.UrlPlaceholder" required="@isRequired" />
    </fieldset>
    <fieldset class="form-group col-md-6" asp-validation-class-for="Text">
        <label asp-for="Text" @if (settings.LinkTextMode == LinkTextMode.Required) { <text> class="required" </text>  }>@T["Link text"]</label>
        <input asp-for="Text" type="text" class="form-control content-preview-text" placeholder="@settings.TextPlaceholder" required="@isTextRequired" />
    </fieldset>
</div>

Liquid template:

div class="page-heading">
   <h1>{{ "Page Not Found" | t }}</h1>
/div>

Generated POT file:

#: OrchardCore.ContentFields\Drivers\LinkFieldDriver.cs:59
#. updater.ModelState.AddModelError(Prefix, T["The url is required for {0}.", context.PartFieldDefinition.DisplayName()]);
msgctxt "OrchardCore.ContentFields.Fields.LinkFieldDisplayDriver"
msgid "The url is required for {0}."
msgstr ""

#: OrchardCore.Modules.GreetingModule\Greeting.vb:94
#. Console.WriteLine(S("Hi {0} ...", name))
msgctxt "OrchardCore.Modules.GreetingModule.Greeting"
msgid "Hi {0} ..."
msgstr ""

#: OrchardCore.ContentFields\Views\LinkField.Edit.cshtml:32
#. <label asp-for="Text" @if (settings.LinkTextMode == LinkTextMode.Required) { <text> class="required" </text>  }>@T["Link text"]</label>
msgctxt "OrchardCore.ContentFields.Views.LinkField.Edit"
msgid "Link text"
msgstr ""

#: TheBlogTheme\Views\Shared\NotFound.liquid:0
msgctxt "TheBlogTheme.Views.Shared.NotFound"
msgid "Page Not Found"
msgstr ""
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].