# Handling long blocks of text to be translated in i18N

**URL:** <https://discourse.aurelia.io/t/handling-long-blocks-of-text-to-be-translated-in-i18n/3168>\
**Category:** Help Requests\
**Created:** [January 18, 2020, 3:50pm UTC](https://discourse.aurelia.io/t/handling-long-blocks-of-text-to-be-translated-in-i18n/3168 "2020-01-18T15:50:38Z")\
**Posts on this page:** 12\
**Page:** 2

<div class="post-metadata">

**Author:** ![kyttike](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/kyttike/32/1398_2.png) [@kyttike](https://discourse.aurelia.io/u/kyttike)\
**Post date:** [January 20, 2020, 7:14am UTC](https://discourse.aurelia.io/t/handling-long-blocks-of-text-to-be-translated-in-i18n/3168/21 "2020-01-20T07:14:43Z")

</div>

In my case, I put the end result in the ‘dist’ folder along with other static assets (like images and svgs)

process-json.ts

```
import * as gulp from 'gulp';
import * as project from '../aurelia.json';
import * as json5 from 'gulp-json5-to-json';

export default function processJson() {
  // Locales processor
  return gulp
    .src(project.jsonProcessor.source, { since: gulp.lastRun(processJson) })
    .pipe(json5())
    .pipe(gulp.dest(project.jsonProcessor.output));
}

```

aurelia.json jsonProcessor section

```
  "jsonProcessor": {
    "source": [
      "src/i18n/**/*.json5"
    ],
    "output": "dist/i18n"
  },
```

---

<div class="post-metadata">

**Author:** ![zewa666](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/zewa666/32/19_2.png) [@zewa666](https://discourse.aurelia.io/u/zewa666)\
**Post date:** [January 20, 2020, 12:06pm UTC](https://discourse.aurelia.io/t/handling-long-blocks-of-text-to-be-translated-in-i18n/3168/22 "2020-01-20T12:06:32Z")

</div>

I fear you’d have to create a minimal repro on GitHub or somewhere so I can take a look at. I’ve just created a fresh new project and it worked as described so I guess there is just one more little gotcha hidden somewhere.

---

<div class="post-metadata">

**Author:** ![jeremyholt](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/jeremyholt/32/1098_2.png) [@jeremyholt](https://discourse.aurelia.io/u/jeremyholt)\
**Post date:** [January 20, 2020, 1:03pm UTC](https://discourse.aurelia.io/t/handling-long-blocks-of-text-to-be-translated-in-i18n/3168/23 "2020-01-20T13:03:33Z")

</div>

I’ve just given you full access to the app.

`main.ts` is setup for the old working json. Just uncomment the relevant bits

---

<div class="post-metadata">

**Author:** ![zewa666](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/zewa666/32/19_2.png) [@zewa666](https://discourse.aurelia.io/u/zewa666)\
**Post date:** [January 20, 2020, 1:24pm UTC](https://discourse.aurelia.io/t/handling-long-blocks-of-text-to-be-translated-in-i18n/3168/24 "2020-01-20T13:24:32Z")

</div>

thx @jeremyholt. I’ve created a new repo showing how that is supposed to work. [https://github.com/zewa666/aurelia-i18n-with-yml](https://github.com/zewa666/aurelia-i18n-with-yml)

From looking at your application I can’t really figure out what went wrong, since if you inspect my sample I had the translations done as you have. What is different though is how you host those files. In the CLI example of mine I’ve just pulled out the locales folder into root and accessing them from there. But in your C# project that might be different. I saw the copy task in your aurelia.json configuration so perhaps your backend isn’t serving the files properly.

Since you have `debug: true` do you see any weird outputs in your console?

EDIT: can’t run your sample since I’m on Mac or alternatively Linux at home ☹

---

<div class="post-metadata">

**Author:** ![jeremyholt](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/jeremyholt/32/1098_2.png) [@jeremyholt](https://discourse.aurelia.io/u/jeremyholt)\
**Post date:** [January 20, 2020, 3:26pm UTC](https://discourse.aurelia.io/t/handling-long-blocks-of-text-to-be-translated-in-i18n/3168/25 "2020-01-20T15:26:20Z")

</div>

@zewa666 Thanks so much for taking the time to look at this for me. I’ve compared line by line your app with mine. I went through build.ts, transpile.ts, aurelia.json and changed the tiny differences so that both projects are truly identical.

I can see that the translation files are copied correctly to wwwroot/locales.

I think I’ve discovered the problem - just need to find out how to resolve it.

I’m 99% sure that the C# server is not serving up yml files

 ![image](https://canada1.discourse-cdn.com/flex027/uploads/aurelia/original/2X/8/831f382c060af1f12aad4eed8f2dade94912dcfc.png)

If I click on translation.json - the page responds with the json file, but if I click on translation.yml I get 'page not found`.

I’m sure this is the problem.

I’ll report back when I’ve learned how to serve yml pages.

Again, many thanks for your help  
Jeremy

---

<div class="post-metadata">

**Author:** ![jeremyholt](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/jeremyholt/32/1098_2.png) [@jeremyholt](https://discourse.aurelia.io/u/jeremyholt)\
**Post date:** [January 20, 2020, 3:46pm UTC](https://discourse.aurelia.io/t/handling-long-blocks-of-text-to-be-translated-in-i18n/3168/26 "2020-01-20T15:46:05Z")

</div>

OK - I needed to add a content provider for yml.

The code needed in Startup is:

This saga should probably be added to the documentation somewhere.

```auto
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseBrowserLink();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            Globalization.Configure(app);
            
            var provider = new FileExtensionContentTypeProvider();
            provider.Mappings[".yml"] = "text/plain";
            
// this is the bit that adds the yml files
            app.UseStaticFiles(new StaticFileOptions
            {
                FileProvider = new PhysicalFileProvider(
                    Path.Combine(Directory.GetCurrentDirectory(),"wwwroot","locales")),
                RequestPath = "/locales",
                ContentTypeProvider = provider
            });
            
            app.UseFileServer(new FileServerOptions {EnableDefaultFiles = true, EnableDirectoryBrowsing = false});
            app.UseRouting();

            app.UseAuthentication();
            app.UseAuthorization();
            app.UseHttpsRedirection();
            SwaggerInitialize.Configure(app);

            app.UseEndpoints(endpoints => endpoints.MapDefaultControllerRoute().RequireAuthorization());

            Log.Logger.Information("Successfully ran Startup.Configure()");
        }

```

Again - thanks so much for everyone’s help - I would never have got here on my own!

---

<div class="post-metadata">

**Author:** ![jeremyholt](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/jeremyholt/32/1098_2.png) [@jeremyholt](https://discourse.aurelia.io/u/jeremyholt)\
**Post date:** [January 20, 2020, 4:07pm UTC](https://discourse.aurelia.io/t/handling-long-blocks-of-text-to-be-translated-in-i18n/3168/27 "2020-01-20T16:07:54Z")

</div>

Just out of interest sake, the `>-` symbol appears to be a legitimate multiline key

 ![image](https://canada1.discourse-cdn.com/flex027/uploads/aurelia/original/2X/7/7773977059997fe0c6bd94458c35aab7f71633cb.png)

The app I’m using to help with the translations [https://github.com/gilmarsquinelato/i18n-manager](https://github.com/gilmarsquinelato/i18n-manager) inserts this symbol into the yaml, and it seems to be working fine.

---

<div class="post-metadata">

**Author:** ![jeremyholt](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/jeremyholt/32/1098_2.png) [@jeremyholt](https://discourse.aurelia.io/u/jeremyholt)\
**Post date:** [January 20, 2020, 4:12pm UTC](https://discourse.aurelia.io/t/handling-long-blocks-of-text-to-be-translated-in-i18n/3168/28 "2020-01-20T16:12:22Z")

</div>

Last question - I promise!

I use Google Translate for translating French and Portuguese. It does a pretty good job, and I’m fluent enough in both languages to spot any silly errors.

However, I also need to translate into Vietnamese. My friends in Vietnam tell me that Google is atrocious in doing the translation.

Does anyone have any experience of translating into Vietnamese, or could suggest a cheap (preferably free) service that can do the translations?

Mind you, now that I’ve moved over to yaml , the files are much easier to hand over to a non-programmer and ask him to do the translation.

---

<div class="post-metadata">

**Author:** ![zewa666](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/zewa666/32/19_2.png) [@zewa666](https://discourse.aurelia.io/u/zewa666)\
**Post date:** [January 20, 2020, 6:32pm UTC](https://discourse.aurelia.io/t/handling-long-blocks-of-text-to-be-translated-in-i18n/3168/29 "2020-01-20T18:32:50Z")

</div>

First of all, glad that you got it working. Was a hard ride but you’ve eventually made it. Congratz 🙂

Looking at your FileExtTypeProvider, I’d suggest to switch the mime type to the correct one for yml `application/x-yaml`, which resembles `application/json` quite well.

I’m defintely new to yaml myself so good to know that \>- is possible as well.

Talking about translations, the guys behind i18next have a service called [Locize](https://locize.com/services.html). On their [services page](https://locize.com/services.html) they’re listing a few partners which might be a good start for your search.

---

<div class="post-metadata">

**Author:** ![jeremyholt](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/jeremyholt/32/1098_2.png) [@jeremyholt](https://discourse.aurelia.io/u/jeremyholt)\
**Post date:** [January 20, 2020, 8:47pm UTC](https://discourse.aurelia.io/t/handling-long-blocks-of-text-to-be-translated-in-i18n/3168/30 "2020-01-20T20:47:35Z")

</div>

Changed the file content provider as you suggested. It’s still working 🙂

Checked out Locize - very interesting - I’ll give it a go when I’ve finished the app.

Again - many, many thanks for your help  
Jeremy

---

<div class="post-metadata">

**Author:** ![zewa666](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/zewa666/32/19_2.png) [@zewa666](https://discourse.aurelia.io/u/zewa666)\
**Post date:** [January 20, 2020, 10:22pm UTC](https://discourse.aurelia.io/t/handling-long-blocks-of-text-to-be-translated-in-i18n/3168/31 "2020-01-20T22:22:21Z")

</div>

The best thanks is to spread the word about Aurelia 😉

---

<div class="post-metadata">

**Author:** ![khuongduybui](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/khuongduybui/32/44_2.png) [@khuongduybui](https://discourse.aurelia.io/u/khuongduybui)\
**Post date:** [January 20, 2020, 10:49pm UTC](https://discourse.aurelia.io/t/handling-long-blocks-of-text-to-be-translated-in-i18n/3168/32 "2020-01-20T22:49:32Z")

</div>

I do have experience of translating into Vietnamese but you don’t want to hire me (it’s not cheap).  
Unfortunately there are no reliable automated solutions for English - Vietnamese translation yet; I have tried Amazon, Microsoft, Google, Babel, etc.  
Your best bet would be a professional translation service, such as [https://translated.com/](https://translated.com/)

[Previous page](https://discourse.aurelia.io/t/handling-long-blocks-of-text-to-be-translated-in-i18n/3168.md?page=1)
