/**
         * Retrieves the plural translation for msgid1.
         *
         * @param env
         * @param domain
         * @param category
         * @param msgid1
         * @param msgid2
         *
         * @return translation found, else msgid1 if n == 1, else msgid2
         */
        private StringValue translate(Env env,
                                      GettextDomain domain,
                                      CharSequence category,
                                      StringValue msgid1,
                                      StringValue msgid2,
                                      int quantity,
                                      Value [] args)
        {
            Locale locale = env.getLocaleInfo().getMessages().getLocale();

            GettextResource resource = getResource(env,
                                                   domain.getPath(),
                                                   locale,
                                                   category,
                                                   domain.getName());

            StringValue unicodeTranslation
                = resource.getTranslation(msgid1, quantity);

            if (unicodeTranslation == null)
            {
                unicodeTranslation = errorReturn(msgid1, msgid2, quantity);
            }

            StringValue translation = msgid1.create(
                env, unicodeTranslation, domain.getCharset());

            return(format(env, translation, args));
        }
Ejemplo n.º 2
0
        public GettextDomain getDomain(Env env, string name)
        {
            GettextDomain domain = _domains.get(name);

            if (domain == null)
            {
                domain = new GettextDomain(env, name);
                _domains.put(name, domain);
            }

            return(domain);
        }
        /**
         * Changes root directory of domain.
         *
         * @param env
         * @param domain
         * @param directory
         * @return directory
         */
        public Value bindtextdomain(Env env,
                                    string domainName,
                                    StringValue directory)
        {
            GettextDomain domain = getDomain(env, domainName);

            domain.setPath(env, directory);

            if (domain.getPath() == null)
            {
                return(BooleanValue.FALSE);
            }
            else
            {
                return(directory);
            }
        }