Skip to content

Instantly share code, notes, and snippets.

View dixonsiu's full-sized avatar

Dixon Siu dixonsiu

View GitHub Profile
@dixonsiu
dixonsiu / i18next_tips.md
Created August 24, 2017 23:57
Make sure you specify "[html]" when assigning "data-i18n" attribute to avoid escaped characters!!

I have defined the following strings.

var sTerm="2017/08/01";
var eTerm="2017/09/01";

The following will produce escaped "/" as "/".

$("#refSearchTerm").attr("data-i18n","glossary:survey.surveyPeriod").localize({ startDate: sTerm, endDate: eTerm });

2017/08/01 ~ 2017/09/01
@dixonsiu
dixonsiu / passing_options_to_localize.md
Created August 21, 2017 08:01
Proper way to translate sentence with variable

Modifying element's attribute does not work.

    is.displaySearchResult = function(count) {
        $('#searchResult')
            .attr("data-i18n", "candidateFilter:searchResult")
            .attr("data-i18n-options", '{ "count": ' + count + ' }')
            .localize();
    };

Passing the data-i18n-options as options of localize.

@dixonsiu
dixonsiu / sample.js
Created August 4, 2017 05:59
Look up special cookie instead of i18next to avoid conflicting settings in same domain
i18next
.use(i18nextXHRBackend)
.use(i18nextBrowserLanguageDetector)
.init({
detection: {
lookupCookie: "i18nextFujitsu"
},
fallbackLng: 'en',
debug: true,
backend: {
@dixonsiu
dixonsiu / convert_link.py
Last active April 27, 2021 20:22
Python scripts for Pandoc
$('dispMsg').html(i18next.t("msg.error.fileNotFound");
@dixonsiu
dixonsiu / change_attr.md
Created August 3, 2017 04:41
i18next tips

Issue

When message/label is translated and written directly to the HTML tag, switching to other language will not re-translate such HTML tag.

Wrong way

  1. Execute the following JavaScript to put English message.

     $('dispMsg').html(i18next.t("msg.error.fileNotFound");
    
  2. Result.

For my testing environment

Add

  1. Calorie Smile

    mklink /D Y:\Apache24\htdocs\hn-app-genki__\src Z:\K5\Personium\forked\calorie-smile-app\src

  2. UnitManager

    mklink /D Y:\Apache24\htdocs\unit-manager Z:\K5\Personium\forked\unit-manager\src

@dixonsiu
dixonsiu / pandoc_filter_procedures.md
Last active June 9, 2021 01:15
How to convert markdown link to html using Pandoc

How to convert markdown link to html using Pandoc

Issue

Pandoc cannot convert a link's URL as expected.
Markdown:

[Document](./document.md)

HTML:

Document