Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use same translations in multiple projects #62

Open
monderino opened this issue Sep 21, 2023 · 6 comments
Open

Use same translations in multiple projects #62

monderino opened this issue Sep 21, 2023 · 6 comments

Comments

@monderino
Copy link

Hi,

I created a Blazer Server app with and used the i18nText. Everything works perfect. ;)
Now I created a second app in my solution and I want to use the same translations here.

Is there a way to do that without creating everything twice?

Thanks and best regards
Sven

@jsakamoto
Copy link
Owner

@monderino
You can define your common localized text tables in a Razor class library, and it can be used from any other Blazor projects with a project reference. I created a sample project and attached it.

📦Use same translations in multiple projects.zip

It that a helpful method for you?

@monderino
Copy link
Author

Hi @jsakamoto,

yes, very nice.

Thank you very much.

@monderino
Copy link
Author

Hi,
I refactored my project but I end up in a problem, maybe you have an idea ;)
So I created one razor library which contains my translation files and this library is added to different Blazor projects.
Locally everything works quite well, but in my online system the translation do not show up.
I build the project in a github action and I use a normal dotnet publish command. I realized, in the online system the translation files are missing in the /wwwroot/_content folder
Screenshot 2023-10-16 at 10 57 04

Do you have any idea why this happen?

Thank you very much.

Best Sven

@monderino monderino reopened this Oct 16, 2023
@monderino
Copy link
Author

There is another issue, that the @types folder with the source generated files not appear. Not in the translation and blazor projects.
Therefore I this to my project file to copy the generated files:

 <!-- Store generated files in file system not only in memory  -->
    <PropertyGroup > 
        <EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
        <CompilerGeneratedFilesOutputPath>Generated</CompilerGeneratedFilesOutputPath>
    </PropertyGroup>
    
    <!--  Run the item group only on debug not in release mode -->
    <ItemGroup Condition="'$(Configuration)' == 'Debug'">
        <!-- Include the output of source generated files in the compilation -->
        <Compile Remove="Generated\**" />
    </ItemGroup>

Maybe this is related to the issue above.

@jsakamoto
Copy link
Owner

jsakamoto commented Oct 17, 2023

@monderino Thank you for your reporting.
I wish I could investigate this problem immediately, but I can't right now because I'm a bit busy with another task. Please give me more time. Sorry for the inconvenience.

P.S.

that the @types folder with the source generated files not appear

The latest version of the I18n text library no longer need to generate any files in the @types folder.

@monderino
Copy link
Author

@jsakamoto
alright, no problem.

Thank you very much for your help. If you need any further information, please let me know.

Best
Sven

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants