Skip to content

Instantly share code, notes, and snippets.

View bosskovic's full-sized avatar

Marko Bošković bosskovic

  • Jomb AG
  • Novi Sad, Serbia
View GitHub Profile
@bosskovic
bosskovic / lingoChecks_examples
Last active December 14, 2015 20:19
Some examples of lingoChecks syntax in the resource files
lh-check {min: 2, max:-3, placeholders:false, terms: lingohub}
lh-check {terms:[lingohub, Github]}
lh-check { min: %60 }
lh-check {placeholders:true, terms: [lingohub, Github], min: +5, max:110%}
# located in the navbar
# lh-check { max: 25, placeholders: true }
# should not be wrapped
hello_user = Hello {username}
# located on the landing page
# lh-check { min: 90%, max: 110%, terms: [iOS, Android] }
localize_bullet = Localize your product on iOS, Android or any other major platform. We support all files and formats, streamlined and hassle-free.
# this description and the following lingCheck belong to the commented out translation, so both will be ignored on import
@bosskovic
bosskovic / example.yml
Last active December 15, 2015 23:59
YAML resource file example
# this comment is ignored because it is not directly followed by a key-value pair
en:
# this comment is also ignored,
# because it is followed by a key that has children nodes
header:
hello_user : Hello %{username}
# comments are treated as translation descriptions
# belonging to the key-value pair that follows
# lingochecks as well
@bosskovic
bosskovic / resources.resjson
Last active December 15, 2015 23:59
RESJSON resource file example
{
"hello_user" : "Hello {username}",
"_welcome.comment" : "keys with .comment suffix are treated as translation descriptions belonging to that key-value pair",
"_welcome.comment" : "multiple comments for the same key-value pair are allowed.",
"welcome" : "Welcome to Lingohub! this is your {visit_count} visit.",
"_welcome.comment" : "lh-check {placeholders:true, terms: Lingohub, min: +5, max:110%}"
}
@bosskovic
bosskovic / example.resx
Created April 9, 2013 09:18
example of RESX/RESW resource file
<?xml version="1.0" encoding="utf-8"?>
<root>
<data name="Common_AuthenicationFailed" xml:space="preserve">
<value>Authentifikation fehlgeschlagen</value>
</data>
<!-- single line comment -->
<data name="Common_Billable" xml:space="preserve">
<value>Verrechenbar</value>
</data>
<!-- multi
@bosskovic
bosskovic / line-break_lh-check_example
Last active December 16, 2015 09:19
Example of line breaks in lh-check comment in the resource files
# lh-check { linebreaks: false }
hello_user = Hello %{username}
# linebreak lh-check in combination with other lh-checks
# lh-check { min: 90%, max: 110%, terms: [iOS, Android], linebreaks: true }
localize = Localize your product on iOS, Android or any other major platform. \n
We support all files and formats, streamlined and hassle-free.
@bosskovic
bosskovic / multilingual_static_website_directory_structure
Created June 28, 2013 16:52
Example of multilingual static website directory structure
de
images
products
main.html
en
images
products
main.html
fr
images
@bosskovic
bosskovic / localizing_strings_with_string_array.php
Last active December 19, 2015 04:49
Example of localizing strings with string array
<?php
$GLOBALS["messages"] = array (
'en'=> array(
'Monday' => 'Monday',
'Tuesday' => 'Tuesday',
'Wednesday' => 'Wednesday',
'Thursday' => 'Thursday',
'Friday' => 'Friday',
'Saturday' => 'Saturday',
'Sunday' => 'Sunday'
@bosskovic
bosskovic / de.txt
Created July 1, 2013 11:28
Example of localization using json
{
"Monday":"Montag",
"Tuesday":"Dienstag",
"Wednesday":"Mittwoch",
"Thursday:"Donnerstag",
"Friday":"Freitag",
"Saturday":"Samstag",
"Sunday":"Sonntag"
}
@bosskovic
bosskovic / json_localization.php
Last active August 16, 2017 05:01
Example of localization using json
<?php
// the original of this code can be found on:
// http://www.mind-it.info/2010/02/22/a-simple-approach-to-localization-in-php/
function localize($phrase) {
/* Static keyword is used to ensure the file is loaded only once */
static $translations = NULL;
if (is_null($translations)) {
$lang_file = '/lang/' . $_SESSION["locale"] . '.txt';
/* If no instance of $translations has occured load the language file */