// I18n is slightly modified version of babilu.js from Tore Darell

var I18n = I18n || (function() {
    // Replace {{foo}} with obj.foo
    function interpolate(string, object) {
        return string.replace(/\{\{([^}]+)\}\}/g, function() {
            return object[arguments[1]] || arguments[0];
        });
    };

    // Split "foo.bar" to ["foo", "bar"] if key is a string
    function keyToArray(key) {
        if(!key) {
            return [];
        }
        if(typeof key != "string") {
            return key;
        }
        return key.split('.');
    };

    // Looks up a translation using an array of strings where the last
    // is the key and any string before that define the scope. The
    // current locale is always prepended and does not need to be
    // provided. The second parameter is an array of strings used as
    // defaults if the key can not be found. If a key starts with ":"
    // it is used as a key for lookup.  This method does not perform
    // pluralization or interpolation.
    function lookup(keys, defaults) {
        var i = 0, value = I18n.translations;
        defaults = (typeof defaults === "string") ? [defaults] : (defaults || []);
        while(keys[i]) {
            value = value && value[keys[i]];
            i++;
        }
        if(value) {
            return value;
        } else {
            if(defaults.length === 0) {
                return null;
            } else if (defaults[0].substr(0,1) === ':') {
                return lookup(keys.slice(0, keys.length - 1).concat(keyToArray(defaults[0].substr(1))), defaults.slice(1));
            } else {
                return defaults[0];
            }
        }
    };

    // Returns other when 0 given
    function pluralize(value, count) {
        if(count === undefined) return value;
        return count === 1 ? value.one : value.other;
    };

    // Works mostly the same as the Ruby equivalent, except there are
    // no symbols in JavaScript, so keys are always strings. The only
    // time this makes a difference is when differentiating between
    // keys and values in the defaultValue option. Strings starting
    // with ":" will be considered to be keys and used for lookup,
    // while other strings are returned as-is.
    function translate(key, options) {
        if(typeof key != "string") {
            // Bulk lookup
            var a = [], i;
            for(i = 0; i < key.length; i++) {
                a.push(translate(key[i], options));
            }
            return a;
        } else {
            options = options || {};
            options.defaultValue = options.defaultValue || null;
            key = keyToArray(options.scope).concat(keyToArray(key));
            var value = lookup(key, options.defaultValue);
            if(typeof value !== "string" && value) {
                value = pluralize(value, options.count);
            }
            if(typeof value === "string") {
                value = interpolate(value, options);
            }
            return value;
        }
    }

    return {
        translate: translate,
        t: translate
    };
})();

I18n.locale = I18n.locale || "en";
I18n.translations = I18n.translations || {"activerecord": {"attributes": {"customer_message": {"contact_name": "Person to contact","fax_number": "Fax","name": "Surname","phone_number": "Telephone","postal_address": "Address"},"customer_quote": {"arrival_at": "Return date","arrival_place": "Destination","departure_at": "Departure date","departure_place": "Departure","people_count": "Number of people","round_trip": "Return journey"},"customer_reclamation": {"line": "Line","occured_at": "Date of incident","stop_area": "Stop","vehicule_id": "Bus number"}},"errors": {"messages": {"accepted": "must be accepted","blank": "can't be blank","confirmation": "doesn't match confirmation","empty": "can't be empty","equal_to": "must be equal to {{count}}","even": "must be even","exclusion": "is reserved","greater_than": "must be greater than {{count}}","greater_than_or_equal_to": "must be greater than or equal to {{count}}","inclusion": "is not included in the list","invalid": "is invalid","less_than": "must be less than {{count}}","less_than_or_equal_to": "must be less than or equal to {{count}}","not_a_number": "is not a number","odd": "must be odd","taken": "has already been taken","too_long": "is too long (maximum is {{count}} characters)","too_short": "is too short (minimum is {{count}} characters)","wrong_length": "is the wrong length (should be {{count}} characters)"},"models": null,"template": {"body": "There were problems with the following fields:","header": {"one": "1 error prohibited this {{model}} from being saved","other": "{{count}} errors prohibited this {{model}} from being saved"}}},"models": {"customer_message": "Message","customer_quote": "Get a quote","customer_reclamation": "Complaint","customer_suggestion": "Suggestion"}},"customer_messages": {"create": {"flash": {"error": "Please complete the information","success": "Thank you, your message has been sent"}},"new": {"header": "This form can be used to ask for information, inform us of an incident or ask us for a quote for a \"special service\".\n\nPlease complete it in detail so that we can send you a precise response as swiftly as possible.\n","object_name": "your message","quote": {"header": "You would like to benefit from a specific service. We will offer our full professionalism to bring you maximum satisfaction.\n"},"reclamation": {"header": "You would like to inform us of an incident or inconvenience encountered on our network\n","pre_message": "Please describe the incident in as much detail as possible"},"submit": "Send","suggestion": {"header": "You would like to share an idea or ask for documentation \u2026\n"},"title": "Write to us"}},"date": {"abbr_day_names": ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],"abbr_month_names": [null,"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"day_names": ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],"formats": {"default": "%Y-%m-%d","long": "%B %d, %Y","short": "%b %d"},"month_names": [null,"January","February","March","April","May","June","July","August","September","October","November","December"],"order": ["year","month","day"]},"datetime": {"distance_in_words": {"about_x_hours": {"one": "about 1 hour","other": "about {{count}} hours"},"about_x_months": {"one": "about 1 month","other": "about {{count}} months"},"about_x_years": {"one": "about 1 year","other": "about {{count}} years"},"half_a_minute": "half a minute","less_than_x_minutes": {"one": "less than a minute","other": "less than {{count}} minutes"},"less_than_x_seconds": {"one": "less than 1 second","other": "less than {{count}} seconds"},"over_x_years": {"one": "over 1 year","other": "over {{count}} years"},"x_days": {"one": "1 day","other": "{{count}} days"},"x_minutes": {"one": "1 minute","other": "{{count}} minutes"},"x_months": {"one": "1 month","other": "{{count}} months"},"x_seconds": {"one": "1 second","other": "{{count}} seconds"}}},"itineraries": {"form": {"arrival": "Arrival","arrival_sample": "e.g.: Gare","default_message": "Please fill in the form.","departure": "Departure","departure_sample": "e.g.: Mairie","invalid": "invalid request","missing_arrival": "Please fill in your destination.","missing_departure": "Please enter a place of departure.","unknown_arrival": "Sorry, your destination has not been recognised","unknown_departure": "Sorry, your departure has not been recognised"},"helper": {"mailto": {"header": "The following link leads to a route search between {{departure}} and {{arrival}}:","subject": "Route search"},"select_hour": {"format": "at %I%p","symbolic": {"afternoon": "on afternoon","evening": "on evening","morning": "on morning"}},"transport_mode": {"name_for_-1": "Change","name_for_0": "Unknown","name_for_1": "Coach","name_for_10": "Taxi","name_for_11": "TER","name_for_12": "Train","name_for_13": "Mainline train","name_for_14": "Tramway","name_for_15": "Trolleybus","name_for_16": "Private car","name_for_17": "Cycle","name_for_18": "Other","name_for_2": "Air","name_for_3": "Waterborne","name_for_4": "Bus","name_for_5": "Ferry","name_for_6": "Walk","name_for_7": "Underground","name_for_8": "Shuttle","name_for_9": "RER"}},"map": {"from_place": "From this place","from_stop": "From this stop","itinerary": "Route","to_place": "to this place","to_stop": "To this stop"},"new": {"arrival_on": "Arrive","at": "to","departure_on": "Set off","flash": {"no_result": "Sorry, no route corresponds to your request.","retry": "Please try again by changing your search criteria","unavailable_service": "The route planner is momentarily unavailable. Please try again in a minute.","via_stop_place": "We recommend trying again by typing in the nearest station"},"on_day": "on","or": "or","submit": "Search","title": "Your customised journey"},"show": {"arrival": "Arrival","at": "to","correspondence": "Connection","departure": "Departure","direction": "Destination","duration": "Journey time","from": "from","from_date": "From","long_correspondence_in_bicycle": "Bicycle journey","long_correspondence_in_feet": "Journey on foot","long_correspondence_in_taxi": "Taxi journey","next_results": "next results","of_walk": "walk","print": "Print","real_time_info_explanation": "Indicates a journey that may be subject to disruption.  See details of the journey for further information.","send_email": "Email","title": "Search results","to": "to","to_date": "to","transport_mode": "Means of transport","trip_details": "Journey details","wait_time": "Wait"}},"number": {"currency": {"format": {"delimiter": ",","format": "%u%n","precision": 2,"separator": ".","unit": "$"}},"format": {"delimiter": ",","precision": 3,"separator": "."},"human": {"format": {"delimiter": "","precision": 1}},"percentage": {"format": {"delimiter": ""}},"precision": {"format": {"delimiter": ""}}},"places": {"nearest_stations": "Nearby stations"},"process": {"busy": "searching ..."},"stop_area_line_search": {"lines": "Please select a line to see when it goes to the stop {{stop}}"},"stop_area_search": {"cancel": "cancel","example_stop": "e.g.: gare","invalid": "Please enter at least 2 letters","no_result": "No stop corresponds to your search","select_line": "Please select the station and line to see the times trains pass through","stop_input_label": "Stop","submit": "search","success": "Your search was successful","title": "The timetable at your stop"},"support": {"array": {"sentence_connector": "and","skip_last_comma": false}},"time": {"am": "am","formats": {"default": "%a, %d %b %Y %H:%M:%S %z","long": "%B %d, %Y %H:%M","short": "%d %b %H:%M"},"pm": "pm"},"timetable_at_stop_search": {"connected_lines": "Other connection lines","date_field_label": "Date","destination": "Destination","destination_note": "to {{location}}","direction": "Destination","get_from": "Set off from the stop","get_to": "Come to the stop","itinerary_link_guide_text": "See how...","line": "Line","no_connected_lines": "Only line {{line}} goes to stop {{stop}}. There is no connecting line.","no_result": "This line does not go to this stop on this date.","on_day": "on","or": "or","print_friendly": "Printable version","print_friendly_title": "Times at which services come through here - printable version","print_guide_text": "The times corresponding to the other destinations are asterisked","stop": "Stop","submit_date": "Refresh","timetable_guide_text": "Please click on the time to find out the service","title": "Times at which the line {{line}} comes to the stop {{stop}}","updated": "The timetable has been updated"}};
