Coder Social home page Coder Social logo

dotnetplus / reswplus Goto Github PK

View Code? Open in Web Editor NEW
119.0 7.0 9.0 1.86 MB

Unleash your resw files with this Visual Studio extension: auto generation of strongly typed static properties, support of pluralization, strongly typed string formatting, etc...

License: MIT License

C# 85.27% HTML 1.51% C++ 9.85% C 0.17% Visual Basic .NET 3.19%
visual-studio localization uwp uwp-dev dotnet-core dotnet-standard resw

reswplus's Introduction

ReswPlus - Advanced File Code Generator for Resw files.

Type Compatibility LanguageSupported GitHub

Now available for Visual Studio 2022

ReswPlus is a Visual Studio extension enriching your existing .resw files with many highly valuable features:

  • Access to strings via strongly typed static properties.
  • Automatically generate methods to format your strings
    • Support typed and named parameters, literal strings, string references and Macros
  • Pluralization support (for 196 languages!).
    • Support empty states when the number of items is zero.
  • Add HTML markups to your strings (bold, italic, hyperlinks, etc...)
  • Variants support
  • Generate a Markup extension to access to your strings with compile-time verification.

Supported:

  • C#, VB.Net, C++/CX and C++/WinRT.

reswplus

Resw Resw with ReswPlus Resx Android XML (for reference)
Modify UI properties via resource files (x:uid)
Generate strongly typed accessors
Generate String Formatting methods
Support Plural forms
Support 'None' state
Support HTML formatting ✅ (indirectly)
Auto-generate methods for string formatting
Support literal strings in string formatter
Support Macros in string formatter
Support String references in string formatter
Strongly typed string formatting
Support Resources in libraries
Support String variants (including genders)

📦 Guide

How to install ReswPlus - Learn how to install ReswPlus
Use ReswPlus in your project - Learn how to use ReswPlus in your projects

🔧 Features

Strongly Typed class generator

ReswPlus can generate a class exposing all strings from your .resw files as strongly typed static properties, providing a compile-time-safe way to access those strings XAML-side or code-side.

🗨 How to generate a strongly typed class

Pluralization

ReswPlus can add support of pluralization and plural forms to your localization strings. Plural forms of 196 languages are currently supported by ReswPlus.

🗨 How to add pluralization
⚙️ Support Empty States
⚙️ Languages supported

String Formatting

To simplify your ViewModels and Views, ReswPlus can directly manage the formatting of your localization and generate strongly typed methods to format your strings.

🗨 How to use String Formatting
⚙️ Named parameters
⚙️ Use String References
⚙️ Use Literal Strings
⚙️ Use Macros

Font style support using HTML tags

Unlike Android localization files, resw files don't support emphasis (bold, italic, underlined...). To address this lack, ReswPlus improves resw files and add support of emphasis using HTML tags (similar to Android).

🗨 How to use HTML formatting

Variants

ReswPlus can support many variants/versions of the same string and allow you to display the one you want based on criteria (variants to support genders, different messages depend on some criteria...)

🗨 How to use variants

.Net String formatting for C++ projects

String formatting in C++ is quite different and more complicated than in C#/VB.Net. ReswPlus provides a way to use the same string templates as you use in .Net (via String.Format) but in your C++ project, making your resource files shareable with .Net libraries and simplifying your code.

🗨 Use .Net String Formatting

Tools

In addition to features to enrich resw files, ReswPlus also provides some interesting tools to improve your productivity or make it easier to use/support resw files in your workflow and localization process.

Convert from/to Android XML files

This is very unfortunate, but not all localization tools and localization companies support recovery files. This is even more of an issue when you want to support Pluralization, as resw does not support it by default. To resolve this issue, ReswPlus now includes a converter to and from Android XML files, a format that supports string pluralization and supported by all tools available on the market.

Simply right click on the resw associated to the default language of your app and select ReswPlus > Export to Android XML format. To convert the Android files once localized, you can use the command-line tool provided with the nuget package (packages/ReswPlusLib.xxxx/Tools/ReswPlusCmd\ReswPlusCmd.exe with the following arguments xml-to-resw -i <folder path> <output path>.

If you don't want to use Visual Studio to convert your resw files to Android XML files, you can use the same command-line tool with the following arguments resw-to-xml -i <resw file path> <output file path>

reswplus's People

Contributors

0xced avatar chrisjshields avatar rudyhuyn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

reswplus's Issues

Does not recognize new C++/WinRT project

If you create a new C++/WinRT project from the IDE, add a .resw file, and then generate the advanced class, it will generate C++/CX code, which will naturally fail to compile.

Shared project: Object reference not set to an instance of an object.

When a resw is in a shared project (I'm using Uno Platform to target both Wasm and UWP so I need it like that) then it throws a NullReferenceException when you try to generate code.

Also huge thanks for providing this extension @rudyhuyn ! Quite baffling actually that VS does not do this out of the box like with WPF!

Visual Studio for MAC Support

In my project I am using Visual Studio 2019 for Mac with Xamarin for development. Is it possible for me to use ReswPlus in Visual Studio for Mac. If possible do you have any documentation describing the use of this library.

🏳‍🌈 Support Genders in localization

We plan to bring gender support to pluralization forms just like ReswPlus made it easier to support them in your .resw files.

Requirements

The implementation must follow the following rules:

  • There is a large number of genders, not limited to 2.
  • Must be inclusive and support neutral and non-binary pronouns (They, Zir, Ze, Hir...)
  • The library should give developers the ability to list the genders they want to support, and not limit them to a static list.
  • It should be noted that with some languages, genders aren't limited to pronouns, and can also impact verbs and adjectives. Example in French:
    • Elle est contente et est allée au cinéma avec nous.
    • Il est content et est allé au cinéma avec nous.
  • Can be combined with pluralization.

Other platforms

Android: No support of genders in localization.
iOS: Support since iOS 8.3 (The official documentation doesn't explain how to do it, so here is an article from the community: https://medium.com/@memani0120/localizing-ios-apps-10c8a21709b8).

Add code generator for C++/WinRT

ReswPlus currently supports C#, VB and C++/CX.

While C++/WinRT project can support C++/CX code, this isn't a perfect solution.

in order to support this additional language, we will have to:

  • Find a way to detect and distinct C++/CX and C++/WinRT projects
  • Abstract CppCodeGenerator and create 2 implementations for C++/CX and C++/WinRT.

ReswPlusKeyExtension duplicate on multiple text resource and same namespace

In my case, I have more than one text resource on my project and put all text resource into my custom namespace "App.Strings".
This issue makes app can't compile because "ReswPlusKeyExtension" is duplicate
Maybe "ReswPlusKeyExtension" enum should be changed if the text resource isn't "Resource" or if there is more than one resw file on the project?
Like "ReswPlusDialogKeyExtension"

NetStandard with ResX support?

Hi!
Since lib generates WinRT related code and uses only ResW, we can't use it in NetStandard1.4 (or any else netstandard) projects.
I see, that repository is called 'ReswPlus', but it looks like self limitation.

I think next solution:

  1. If developer is initializing ReswPlus on .resw file - then use WinRT resources.
  2. If developer is initializing ReswPlus on .resx file - then use .Net resources.
  3. MarkupExtension and other platform specific classes could be in separated nuget package.

Someone could wish markup extensions for Xamarin/Wpf/Avalonia, but it could be implemented in future. WinRT dependency blocks it now.

Thanks.

Support for Uno platform (WinUI3)

I would be very happy if the extension would also work for a project based on uno platform. this would then also support WinUI3 through the namespace.

In order to keep this compatible with UWP, we could set a condition (C#):

using System;
using Windows.ApplicationModel.Resources;
#if WINDOWS_UWP
using Windows.UI.Xaml.Markup;
using Windows.UI.Xaml.Data;
#else
using Microsoft.UI.Xaml.Markup;
using Microsoft.UI.Xaml.Data;
#endif

The solution is not reading properly the xlf file

I don't know if I should blame ReswPlus or Multilingual App Toolkit, but there seem to be some issues with the xlf file
image

I tried to remove the xlf file and it did not have "cascade" effect, the resw plus was still there. Furthermore multilingual app toolkit stopped working. Not that now it's working properly, since I cannot add any new language.

If you want to take a look everything is open source here https://github.com/MarcAnt01/Fluent-Screen-Recorder/tree/2.0

Visual Studio 2022 Support

Installed product versions

  • Visual Studio: 2022 All Versions

Description

Make the extension available in Visual Studio 2022.

Steps to recreate

  1. Download the extension installer.
  2. Run the installer.

Current behavior

Message that it is already installed to all applicable products appears even though it is not installed in Visual Studio 2022.
It is also not listed in Online Extensions in Manage Extensions Visual Studio 2022.

Expected behavior

Installs and works in Visual Studio 2022.

Note: Sorry for the all the extra details. I probably could have stopped with the title on this one.

Doesn't work in VS2022 17.6.3

You have two install options. Searching for it in extension manager and from Microsoft's website. I have installed both in VS2022 17.6.3 and neither options works. ReswPlus is in the menu and I select to create classes and nothing happens. I downloaded the source, built the 2022 VSIX and it also doesn't work. By the way, your directions and Microsoft's website all don't say 2022. I didn't pay attention if those install options were the newest ReswPlus for 2022.

How to use this with Visual Studio 2017?

I read that VS 2017 and 2019 are supported and I would like to see if it will solve a problem I have, but I am limited to use in VS 2017.

For kicks I uncompressed the vsix and increased the range of supported installations. It installed fine and the context menu shows, but when trying to pick the first option I got an error.

The activity log shows...

Unexpected system error mode before loading package [ReswPlusPackage]
CreateInstance failed for package [ReswPlusPackage]Source: &apos;mscorlib&apos; Description: Could not load file or assembly &apos;Microsoft.VisualStudio.Shell.15.0, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a&apos; or one of its dependencies. The located assembly&apos;s manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)&#x000D;&#x000A;System.IO.FileLoadException: Could not load file or assembly &apos;Microsoft.VisualStudio.Shell.15.0, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a&apos; or one of its dependencies. The located assembly&apos;s manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)&#x000D;&#x000A;File name: &apos;Microsoft.VisualStudio.Shell.15.0, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a&apos; ---&gt; System.IO.FileLoadException: Could not load file or assembl.............

Possible to use this for TargetNullValue?

One of the main things I downloaded this is for being able to set TargetNullValue from XAML. I'm only able to set it to a string directly in XAML. While the following compiles:

<TextBlock Text="{x:Bind Key.Name, TargetNullValue={strings:Resources Key=UnknownAlbumText}}"
                                       Style="{StaticResource BodyTextBlockStyle}"
                                       TextWrapping="Wrap"
                                       TextTrimming="CharacterEllipsis"
                                       MaxLines="2"
                                       x:Phase="0"/>

the value does not show up. Any idea if this can be used for this use case?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.