JetBrains IDE how configure multi language file - jetbrains-ide

There are files in the project that contain three languages: Python, HTML, JS.
Languages ​​are between special tags
<mako>
from pyasm.search import Search
</mako>
<html>
<div style="padding-left: 10px;">Hi</div>
</html>
<behavior>
var el = header_el.getElement(".spt_header_account_top");
</behavior>
How to associate these tags with required syntax in PyCharm IDE?

You can try creating the corresponding language injections: create new XML Tag injection in Settings | Editor | Language Injections, specify your tag name (behavior, for example) as Local name:, choose the desired language (JavaScript, for example) as ID:.
You can also inject languages in your tags using Inject language or reference intention available on Alt+Enter:

Related

How to tell JetBrains IDE that template string is JS code

I have an ES6 template string, which represents JS code. If I put <script> tags around it, JetBrains IntelliJ will do syntax highlighting and checking, but not if there are no script tags.
Is there a way to tell JetBrains IDE how to interpret the template string?
It's definitely the presence/absence of the html tag.
IDEA auto-injects HTML in JavaScript string literals/template string if there are HTML tags in it; to inject other languages, you need adding language injection manually - for example, the language can be temporary injected via Inject language or reference intention available on Alt+Enter:
You can also annotate your injection with comments to make it permanent:
//language=JS
const baz = `console.log("test")`
See https://www.jetbrains.com/help/idea/using-language-injections.html for more information

Liferay: localize layout template names

I have written a maven module, which contains my custom layout for liferay. The layout works fine but I also want it's name to be translated in a few languages.
Here's my liferay-layout-templates.xml file:
<?xml version="1.0"?>
<!DOCTYPE layout-templates PUBLIC "-//Liferay//DTD Layout Templates 6.2.0//EN" "http://www.liferay.com/dtd/liferay-layout-templates_6_2_0.dtd">
<layout-templates>
<custom>
<layout-template id="2_columns_layout-75_25" name="myLayout">
<template-path>/2_columns_layout-75_25/2_columns_75_25.tpl</template-path>
<wap-template-path>/2_columns_layout-75_25/2_columns_75_25.wap.tpl</wap-template-path>
<thumbnail-path>/2_columns_layout-75_25/2_columns_75_25.png</thumbnail-path>
</layout-template>
</custom>
</layout-templates>
I tried to delete name attribute and add language keys(which were the same to my template id) and values to my hook module, but it didn't work.
At first I was inclined to state that there's no built-in way to localize layout templates. However, I've looked up the JSP in question (in Liferay's html/portlet/layouts_admin/layout/layout_templates_list.jsp) and found the following line (shortened and edited):
<%= HtmlUtil.escape(LanguageUtil.get(locale,
"layout-template-" + layoutTemplateName, layoutTemplateName)) %>
So it looks like the localization keys that you'll need to use for translating your layout-template's name needs to be starting with "layout-template-" followed by the layout template's own name, e.g. given the xml from your question: layout-template-myLayout=My first localized layout template

Primefaces editor generates span elements

I use primefaces editor within a project (http://www.primefaces.org/showcase/ui/input/editor.xhtml). My problem is that it always generates SPAN elements.
E.g. test is exported as
<span style="font-weight: bold;">test</span>
Instead of this, I need to generate markup (and so for the other functions) liek this:
<b>test</b>
Any idea?
(it is not my personal wish but a need to be compatible with a legacy API)
Instead of <p:editor> use <pe:ckEditor> primefaces extension, and there are various options available for this choose according to your requirement primefaces editor will always generate span for text.

Natural Templating .html (like Thymeleaf) for Node.js

Is there Natural Templating for Node.js
Natural Templating (like Thymeleaf template engine) is when template page or it's part can be perfectly displayed by a browser as a prototype, without being executed at all.
That is, I have template with .html extension, and I can just open in browser to preview it, and use standard HTML dev tools to edit.
UPDATE: I have added answered, that were added in comments. (Do new StackOverflower users fear to add answers?) Hope to hear from developers, that actually use those things (just add new answer)
github.com/flatiron/plates (answered by generalhenry)
Plates (short for templates) binds data to markup. Plates has NO
special syntax. It works in the browser and in Node.js.
Active
I have a jinja like template engine in the backend.
My frontend sometimes needs to retrieve data from the server and interpolate with the content of a HTML5 template tag.
I could do that with query selectors. But I want something more closer to thymeleaf or mustache without special syntax (especially not to conflict with my backend template engine and not have any issues when presented in the HTML5 template tag).
So I created this:
https://github.com/marcodpt/tint
While this works in the browser (and that's fine for my personal use), it's not difficult to use a DOM API to port it to node or deno.
<html>
<head>
<script type="module">
import compile from "https://cdn.jsdelivr.net/gh/marcodpt/tint#2.0.0/template.js"
const render = compile(document.getElementById("app"))
render({
message: "Hello World!"
})
</script>
</head>
<body>
<div id="app">
<h1 :text="message">Loading...</h1>
</div>
</body>
</html>
{{ mustache }} (answered by etienne)
Logic-less templates.
Available in Ruby, JavaScript, Python, Erlang, PHP, Perl, Objective-C,
Java, .NET, Android, C++, Go, Lua, ooc, ActionScript, ColdFusion,
Scala, Clojure, Fantom, CoffeeScript, D, and for node.js.
Works great with TextMate, Vim, Emacs, and Coda.
I was using Handlebars.
There are actually quite a few template engines in JavaScript and here you can decide what you need.

multi lingual website html setup

I am currently setting up a multi lingual website that is to support different languages, english and spanish for starters and french in the future.
I have the content etc localized but now I want to make sure that have all meta tags and http headers, lang attribute on body tag, xml:lang etc are correct for the culture selected at the time.
Is there anywhere outline on the internet that outlines what needs to be configured for multi lingual html sites? Anyone have any advice/tips on this.
As far as I know, there are no such "must haves". All of these are optional (maybe with an exception of character encoding). What you might need:
Character encoding declaration
That is for sure, you need content type and character encoding declaration:
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
For obvious reasons UTF-8 is recommended.
Language declaration
Language could be declared with lang attribute, which is defined for most of HTML elements. Therefore you can set it document-wide, body-wide or anywhere you please:
<html lang="de">
<body lang="es">
<p lang="pl">Jakiś tekst</p>
</body>
</html>
Of course that would be nice if these tags make sense (unlike in example above), so it is common to set lang tag for body and for paragraphs (if it happens that given paragraph is in different language than body).
The content of lang attribute is two letter ISO 639 language code (ISO 639-1 to be precise). The same applies to xml:lang (which could be declared in XHTML web sites).
Directionality
If it happens that you will face the challenge of localizing web site into Hebrew, Arabic or other Right-To-Left language, you will also need to apply dir attribute. Just like in case of lang, this attribute is optional and could be placed almost anywhere. If it is omitted, dir="LTR" is assumed. Example:
<body lang="ar" dir="RTL">
That's I am afraid it. Multilingual support for web sites is still kind of grey area, and support is not the best to say the least. For example, you would need to care yourself for providing valid formatting of dates, numbers, currencies and similar artifacts.
Also, you would need to remember not to use gems like CSS text-transform: uppercase | lowercase, JavaScript's uppercase and lowercase related functions, as well as JavaScript's toLocalizedString() functions. These gems are very unreliable and doesn't work correctly.

Resources