-
Notifications
You must be signed in to change notification settings - Fork 0
/
analyze.example.js
33 lines (29 loc) · 914 Bytes
/
analyze.example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Use import from "hsa-js"
// import HtmlStringsAffixer from "hsa-js";
import HtmlStringsAffixer from "../src/htmlStringsAffixer.js";
// Example of using HtmlStringsAffixer in a Laravel Blade template
const bladeTemplateContent = `
<div>
<h1>Welcome to our website</h1>
test
<p>{{stayEnjoyment}}</p>
<a href="/contact">Contact us</a> here
there
<h2>Welcome to our website</h2>
1
2
3
</div>
`;
const affixer = new HtmlStringsAffixer({
prefix: "{{ __('", // Prefix to add before string
suffix: "') }}", // Suffix to add after string
ignore: ["#", "_", ">", "^", "*", "="],
warnings: ["%", "{", "(", "}", ")", "$", "'"],
extractions: [
"text", // Since we have only texts
],
});
const result = affixer.analyze(bladeTemplateContent, true);
console.log(result.translatableStrings);
console.log(result.warningStrings);