l10n / (gettext-oriented) PO-File Generator

####Helps to localize your application####

Screenshot)

###Install - WORKS###

dependencies:
  ...  
  l10n: any
pub update
ln -s packages/l10n/mkl10nlocale.dart mkl10nlocale

mkl10nlocale --help

####Install (should work)#### In Dart(-sdk) 1.6

$ pub global activate l10n

should works... - <b>BUT DOES NOT!!!!</b>

You can run the script from any local directory.

$ pub global run l10n:mkl10nlocale --help
pub global activate + run seams not ready! As said - make a symlink and you are done!

###How to use it###

import 'package:intl/intl.dart';
import 'package:intl/intl_standalone.dart';
import 'package:intl/date_symbol_data_local.dart';

import 'package:l10n/l10n.dart';

// This file will be generated by the framework (l10n)
// Uncomment in Step 3
//import 'package:<your package>/locale/messages.dart';

void main(List<String> arguments) {
    final Application application = new Application();

    findSystemLocale().then((final String locale) {
        // Uncomment in Step 3
        // translate.locale = Intl.shortLocale(locale);

        // Step 1 - sourround your text with l10n(...)
        // Try this: print(l10n("This is a test").message);
        print(l10n("This is a test"));  
               
        // Step 2 - run mkl10nlocale -l de,en example/
        
        // Step 3 - add the import-statement for locale/messages.dart
        // + set the locale
        
        // Step 4 - add 'translate' to your print statement
        print(translate(l10n("This is a test")));  
        
        // Step 5 - Translate the entry in your 
        // PO (for example local/de/messages.po
        
        // Step 6 - run mkl10nlocale -l de,en
        
        // Step 7 - run your program 
    });
}
$ dart mini.dart 
SystemLocale: de_AT
Dies ist ein TEST!

####Sub-Translations### Since 0.11.0 Sub-Translations are possible - here is the explanation:

locale/de/.../messages.po: 
    msgid: "Servermessage {{statuscode-400}}."
    msgstr: "Fehlerhafte Anfrage"
    
locale/en/.../messages.po: 
    msgid: "Servermessage {{statuscode-400}}."
    msgstr: ""
    
    final int major = 400;
    
    // This produces a msgid "Servermessage {{status}}." in your PO-File.
    // You can translate it as usual 
    final L10N l = new L10N( "Servermessage {{status}}.", { "status"  : "{{statuscode-${major}}}" });
    expect(l.message,"Servermessage {{statuscode-400}}.");

    // No translation for en - so fallback to msgid
    expect(translate(l),"Servermessage {{statuscode-400}}.");

    // But what we really want is what I call Sub-Translation
    translate.locale = "de";
    expect(translate(l),"Fehlerhafte Anfrage");
    
    /* 
    Internal way of sub-translation: 
      Replace vars in L10N message -> Servermessage {{statuscode-400}}.
      Check if there is a translation - return it, if not, return the msgid
    */
Drawback
You have to add the msgid "Servermessage {{statuscode-400}}." by hand to your POT-File.
The rest is done be the nice merging-feature of l10n/msgmerge

###System requirements### xgettext msginit * msgmerge

These programs are on your system if you are working on Mac or Linux.

(only if you want to generate PO/POT files)

###If you have problems### * Issues

###History ### 0.11.0 - Sub-Translations are possible, msginit gets initialized with utf-8 per default 0.9.0 - Released on pub

###License###

Copyright 2014 Michael Mitterer ([email protected]), 
IT-Consulting and Development Limited, Austrian Branch

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, 
software distributed under the License is distributed on an 
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
either express or implied. See the License for the specific language 
governing permissions and limitations under the License.


If this plugin is helpful for you - please (Circle) me.

Libraries

l10n
l10n.locale
mkl10nlocale