Developer forum

Forum » Dynamicweb 9.0 Upgrade issues » shared translation not used

shared translation not used

Frederik Gadegaard
Reply

Hello, 

In our solution we are using only the shared translations.
However for some reason, translation-keys that already exists in the shared translations keep getting created in the more specific design translation file, which I dont think is the expected behavior? And they get created with the default text for all languages:(

If no key was found anywhere, I would assume that it will be created manually with a default text, and likely it would be in the more specific design tranlation file - but only if it wasnt already in the shared one?


I recently upgraded a  DW8.8xx to DW9.9xx and found out that you no longer can call Translate method with "global" parameter to force  using shared translations like:
@Translate("PhoneTimeToday", "Phone time today", "global") 

And then I removed the "global" paramater everywhere and ensured that they only existed in shared. And this works fine, but some translations (not all) keep appearing in the design translations. 

How is the rules and why does some get re-created in the specific design translations?

 

Kind regards

Frederik

 

 


Replies

 
Oleg Rodionov Dynamicweb Employee
Oleg Rodionov
Reply

Hi,

Perhaps, manual's info about translations and especially logic regarning shared translations will be useful for you.

BR, Oleg QA

 
Frederik Gadegaard
Reply

Hi again, 

Im still experiencing this problem of having translations being automatically created in design-specific-translation files, even though they already exists in the global shared translation file. 

Is this expected behavior? 

I would assume it would just use the shared one if could not find it in a design translation. 

DW version: 9.9.10


Kind regards
Frederik

 
Nicolai Pedersen
Reply

Hi Frederik

It is not an issue we see in other solutions. Could it be that you have more than one design and the other one writes to this file?

Also if you run a template the first time outside pageview context (which has the design and the layout), it cannot find the design specific translation file and will write to the global file.

So in what template do you have a key that has been written to the global translations?

BR Nicolai

 
Frederik Gadegaard
Reply

Hi again Nicolai,

And thank you for the reply! :) 

We have a template file that is located ".../Templates/Designs/HCCargo/frontpage.cshtml".



Which is referencing a master file at ".../Templates/Designs/HCCargo/master.cshtml"
(master file is simplified a lot*)

Which again is referencing two cshtml files.
And there are translations in both the master file and in the two included files, that are being re-created in the design specific translation file under ".../HCCargo" again and again, even though they already exists in the shared translation file. 

And it is not consistent in the when they are being created. The site (which is heavily used everyday) can run for a week without it being a problem, until suddenly a translation.xml file appears under HCCargo design folder with default translations for a number of translation keys that already exists in the shared file.

And I would say that the template is rendered within the pageview context, no? :) 

Kind regards 
Frederik
 

 

 

 

 

 
Nicolai Pedersen
Reply

Yes, that template is rendered in the pageview context.

Masters and includes are put together to one file before being executed, so that should be fine.

The keys that shows up - is it all of them, or some of them? And are you sure that the same keys are not used in other templates? I.e. one that is used by a newsletter or something else on the solution?

What DW version is this?

 
Frederik Gadegaard
Reply

Hi again Nicolai, 

Actually I found out that it is all of the translations that the master.cshtml file + includes contains that are being created.

Some of them could be used other places, but most of them are only referenced within the includes, so I think we can rule that out.

Dynamicweb nuget package: 9.9.10

But I just found out that there are some razor errors. . .
Do you think that could cause the triggering of the translations in the HCCargo design folder maybe?


Errors:
example 1:
2021-05-12 11:15:22.3418|ERROR|Templates|Error executing razor template (Designs/HCCargo_2015/_parsed/404.parsed.cshtml) http://hc-cargo.fr/Admin/Public/404.aspx?404;http://hc-cargo.fr:80/false

System.FormatException: String was not recognized as a valid Boolean.
at System.Boolean.Parse(String value)
at CompiledRazorTemplates.Dynamic.RazorEngine_b0fd904d1cc74cf08b51f8ce5a2cddde.Execute() in D:\Websites\Dynamicweb\hc-cargo.dk\Files\Templates\Designs\HCCargo_2015\_parsed\404.parsed.cshtml:line 1252
at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0. b__0(TextWriter writer)
at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
at Dynamicweb.Rendering.Template.RenderRazorTemplate()

example 2:
2021-05-12 06:22:34.1692|ERROR|Templates|Error compiling razor template (Designs/HCCargo_2015/UserManagement/Login/login.cshtml) http://hc-cargo.dk/Default.aspx?ID=821
RazorEngine.Templating.TemplateCompilationException: Errors while compiling a Template.
Please try the following to solve the situation:
* If the problem is about missing/invalid references or multiple defines either try to load
the missing references manually (in the compiling appdomain!) or
Specify your references manually by providing your own IReferenceResolver implementation.
See https://antaris.github.io/RazorEngine/ReferenceResolver.html for details.
Currently all references have to be available as files!
* If you get 'class' does not contain a definition for 'member':
try another modelType (for example 'null' to make the model dynamic).
NOTE: You CANNOT use typeof(dynamic) to make the model dynamic!
Or try to use static instead of anonymous/dynamic types.
More details about the error:
- error: (44, 54) 'Area' does not contain a definition for 'Values' and no accessible extension method 'Values' accepting a first argument of type 'Area' could be found (are you missing a using directive or an assembly reference?)
- error: (45, 63) 'PageView' does not contain a definition for 'PageCollection' and no accessible extension method 'PageCollection' accepting a first argument of type 'PageView' could be found (are you missing a using directive or an assembly reference?)
- error: (45, 49) The type or namespace name 'Page' does not exist in the namespace 'Dynamicweb.Frontend' (are you missing an assembly reference?)
- warning: (58, 12) 'Logger.ErrorException(string, Exception)' is obsolete: 'Use Error(Exception exception, string message, params object[] args) method instead. Marked obsolete before v4.3.11'
Temporary files of the compilation can be found in (please delete the folder): C:\Windows\TEMP\RazorEngine_cw4qfqs2.ama
The template-file we tried to compile is: D:\Websites\Dynamicweb\hc-cargo.dk\Files\Templates\Designs\HCCargo_2015\UserManagement\Login\login.cshtml
The generated source code is: ...

 

Kind regards 
Frederik

 
Frederik Gadegaard
Reply

Helli again Nicolai,

We still keep having this issue of design-specific translations being created even though they exists in the shared. I just found out that there is a error log (see attached stacktrace below) that has the exact same timestamp as the design translations creation date. 
And I went back 3 earlier couple of days earlier, and could see the same exact coincidence where the same log as seen below was timestamped as there translation file was created. 

Weird thing is though, that the file at this point didnt exists? But maybe multiple http calls to the server generated a need for creating the file in the first place resulting in it being locked by the first one. 

But again I shouldnt be created in the first place in my opinion because all the translations already exists in the shared one.

At the point Im considering having a file watcher that syncs all the translations in the shared and design specific folder at all times having a complete duplicate setup. But thats also a bit of a workaround :s 

Kind regards 
Frederik

Error:

2021-05-17 09:22:10.0599|ERROR|Templates|Error executing razor template (Designs/HCCargo_2015/_parsed/frontpage.parsed.cshtml) http://hc-cargo.it/
System.IO.IOException: The process cannot access the file 'D:\Websites\Dynamicweb\hc-cargo.dk\Files\Templates\Designs\HCCargo_2015\Translations.xml' because it is being used by another process.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
   at Dynamicweb.Rendering.Translation.Source.WriteDocument(XmlDocument document)
   at Dynamicweb.Rendering.Translation.Source.Save()
   at Dynamicweb.Rendering.Translation.Source.UpdateTranslationSource(Source source, IEnumerable`1 newKeys, String designName, IEnumerable`1 cultures)
   at Dynamicweb.Rendering.TemplateBase`1.Translate(String text, String defaultValue, String cultureName)
   at CompiledRazorTemplates.Dynamic.RazorEngine_69afe9dd0fd344c4a2479871d59316fd.Execute() in D:\Websites\Dynamicweb\hc-cargo.dk\Files\Templates\Designs\HCCargo_2015\_parsed\frontpage.parsed.cshtml:line 2414
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

 
Nicolai Pedersen
Reply

Hi Frederik

Not an easy one. It seems that something could be happening here, that DW struggles with. I think we see it on this solution because of the number of translation keys and cultures in your xml file.

My thesis is, that a (relatively large) number of your keys is not translated to all cultures. So when you browse the website, Dynamicweb will try to write these missing translations to the culture of each translation and if 2 different cultures hit the same time, this could happen.

If you take a look at what happens in \Templates\Designs\HCCargo_2015\_parsed\frontpage.parsed.cshtml:line 2414, you can see that you have an unconventional call to the translate method. Could also be related, but I do not think so.

I have made a change to our code on how un-translated keys in specific cultures are handled when not present that I believe should fix this problem. Since we cannot reproduce we cannot be 100% sure. I have send the change for code review and testing and you will get an update when ready. You will need and upgrade of Dynamicweb.dll to get this change. It is currently merged to 9.10 - what version is this solution?

BR Nicolai

 
Frederik Gadegaard
Reply

Hi Nicolai, 

No, I know it was a hard case and appreciate your time on this a lot!! I sadly can't eliminate 100% that we are doing something weird on our end that produces this behavoir also men in line 2414 I would say we just use your translation API on a .cshtml file to generate translations used in a javascript obj which I would assume was fine. 

Our Dynamicweb.dll is version: 9.9.10

Could this issue come from not having a translation.xml file at all in the design folder? I have removed it entirely before. This time I have removed all the keys but kept the translation file and at least we are on day 2 without new translations :) 

Kind regards
Frederik

 
Frederik Gadegaard
Reply

Hi again Nicolai, 

Is it possible to get this fix on:

9.9.10

Or do we need to upgrade to 9.10.xx ? 

Kind regards
Frederik
 

PS the error we see remains the same:
2021-06-21 15:54:54.4870|ERROR|Templates|Error executing razor template (Designs/HCCargo_2015/_parsed/404.parsed.cshtml) http://hc-cargo.de/Admin/Public/404.aspx?404;http://hc-cargo.de:80/false
System.IO.IOException: The process cannot access the file 'D:\Websites\Dynamicweb\hc-cargo.dk\Files\Templates\Designs\HCCargo_2015\Translations.xml' because it is being used by another process.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
at Dynamicweb.Rendering.Translation.Source.WriteDocument(XmlDocument document)
at Dynamicweb.Rendering.Translation.Source.Save()
at Dynamicweb.Rendering.Translation.Source.UpdateTranslationSource(Source source, IEnumerable`1 newKeys, String designName, IEnumerable`1 cultures)
at Dynamicweb.Rendering.TemplateBase`1.Translate(String text, String defaultValue, String cultureName)
at CompiledRazorTemplates.Dynamic.RazorEngine_0059272a04374acba76f2290c0134d00.Execute() in D:\Websites\Dynamicweb\hc-cargo.dk\Files\Templates\Designs\HCCargo_2015\_parsed\404.parsed.cshtml:line 2438
at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0. b__0(TextWriter writer)
at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
at Dynamicweb.Rendering.Template.RenderRazorTemplate()

 
Nicolai Pedersen
Reply

Actually we cannot - Dynamicweb.dll has been converted to C# and the change made in C#. Your version runs the VB version of the dll so we cannot merge....

 

You must be logged in to post in the forum