Hi Maciej, please open a JIRA issue at https://issues.apache.org/jira/browse/ROL and attach your patch to it partly for Apache licensing reasons. Also, that way, even if we don't apply the patch due to lack of time or disagreement it doesn't get lost and can always be referred to later. (BTW, all new and modified JIRA issues automatically send an email to this mailing list, so we're always notified of new patches.)

No, unfortunately we didn't get your original patch, we rarely get pictures and attachments in emails it seems.

Quote:
http://localhost:8083/roller/test/ - search in all languages and return links without locale
No problem there, sounds good.

http://localhost:8083/roller/test/de - search in German language (de) and return links with de locale (post from other languages will not be shown)

This will work as a nice default, and I also like how you don't need to update the themes for this (time-consuming as our number of themes increase.) However, if we get user demand for it, we someday may need to enhance the Velocity macro that creates the search box (I'm assuming some macro is used, I haven't looked at the code) to have it take a Boolean over whether to still search on all blog entries regardless of language on the locale pages. Such a change would not require a theme updating on *our* end but for a user who would just need to customize his own theme with a modified macro call. In other words, I don't see a need to provide a blog reader the ability to choose one or all languages, but the blog *owner* might want to do that, depending on the nature and content of his blog entries. But this does not need to be done now, because nobody's asked for it yet.

Thanks,
Glen

On 07/30/2013 04:52 AM, Maciej Rumianowski wrote:
Okay, this is the second version of the patch. It is much more simpler, only add locale to search fields and perform searches with current locale (or without if locale is not set)

Now when search is performed from:
http://localhost:8083/roller/test/ - search in all languages and return links without locale http://localhost:8083/roller/test/de - search in German language (de) and return links with de locale (post from other languages will not be shown)

WDYT?

Maciej

PS.: Do You get attachments? I attached patch to this message and first one in the Thread. If not I am pasting it below:

Index: app/src/main/java/org/apache/roller/weblogger/business/search/FieldConstants.java
===================================================================
--- app/src/main/java/org/apache/roller/weblogger/business/search/FieldConstants.java (wersja 1508340) +++ app/src/main/java/org/apache/roller/weblogger/business/search/FieldConstants.java (kopia robocza)
@@ -47,4 +47,5 @@
// the transform rules of
                                                  // the analyzer
     public static final String WEBSITE_HANDLE = "handle";
+    public static final String LOCALE = "locale";
 }
Index: app/src/main/java/org/apache/roller/weblogger/business/search/operations/SearchOperation.java
===================================================================
--- app/src/main/java/org/apache/roller/weblogger/business/search/operations/SearchOperation.java (wersja 1508340) +++ app/src/main/java/org/apache/roller/weblogger/business/search/operations/SearchOperation.java (kopia robocza)
@@ -54,7 +54,7 @@

     private static String[] SEARCH_FIELDS = new String[] {
             FieldConstants.CONTENT, FieldConstants.TITLE,
-            FieldConstants.C_CONTENT, FieldConstants.CATEGORY };
+ FieldConstants.C_CONTENT, FieldConstants.CATEGORY, FieldConstants.LOCALE };

     // private static BooleanClause.Occur[] SEARCH_FLAGS = new
     // BooleanClause.Occur[] {
@@ -73,6 +73,7 @@
     private String term;
     private String websiteHandle;
     private String category;
+    private String locale;
     private String parseError;

     private int nMax = 500; // Limit documents.
@@ -144,6 +145,16 @@
                 query = bQuery;
             }

+            Term tLocale = IndexUtil.getTerm(FieldConstants.LOCALE,
+                    locale);
+
+            if (tLocale != null) {
+                BooleanQuery bQuery = new BooleanQuery();
+                bQuery.add(query, BooleanClause.Occur.MUST);
+ bQuery.add(new TermQuery(tLocale), BooleanClause.Occur.MUST);
+                query = bQuery;
+            }
+
searchresults = searcher.search(query, null/* Filter */, nMax,
                     SORTER);

@@ -227,4 +238,14 @@
         this.category = category;
     }

+    /**
+     * Sets the locale.
+     *
+     * @param locale
+     *            the new locale
+     */
+    public void setLocale(String locale) {
+        this.locale = locale;
+    }
+
 }
Index: app/src/main/java/org/apache/roller/weblogger/business/search/operations/IndexOperation.java
===================================================================
--- app/src/main/java/org/apache/roller/weblogger/business/search/operations/IndexOperation.java (wersja 1508340) +++ app/src/main/java/org/apache/roller/weblogger/business/search/operations/IndexOperation.java (kopia robocza)
@@ -125,6 +125,10 @@
         doc.add(new Field(FieldConstants.TITLE, data.getTitle(),
                 Field.Store.YES, Field.Index.ANALYZED));

+        // text
+        doc.add(new Field(FieldConstants.LOCALE, data.getLocale(),
+                Field.Store.YES, Field.Index.ANALYZED));
+
// index the entry text, but don't store it - moved to end of block
         // unstored
         doc.add(new Field(FieldConstants.CONTENT, data.getText(),
Index: app/src/main/java/org/apache/roller/weblogger/ui/rendering/model/SearchResultsModel.java
===================================================================
--- app/src/main/java/org/apache/roller/weblogger/ui/rendering/model/SearchResultsModel.java (wersja 1508340) +++ app/src/main/java/org/apache/roller/weblogger/ui/rendering/model/SearchResultsModel.java (kopia robocza)
@@ -121,6 +121,10 @@
search.setCategory(searchRequest.getWeblogCategoryName());
         }

+        if (searchRequest.getLocale() != null) {
+            search.setLocale(searchRequest.getLocale());
+        }
+
         // execute search
         indexMgr.executeIndexOperationNow(search);



2013/7/30 Maciej Rumianowski <maciej.rumianow...@gmail.com <mailto:maciej.rumianow...@gmail.com>>




    2013/7/29 Glen Mazza <glen.ma...@gmail.com
    <mailto:glen.ma...@gmail.com>>

        Oh, um, never mind on one point -- I was complaining below
        about having URLs like
        http://www.jroller.com/gmazza/en/entry/myblogentry and
        http://www.jroller.com/gmazza/entry/myblogentry splitting
        Google Analytics results, I just realized *I* can turn off the
        multiple languages option myself, and then "/en/" version no
        longer is a valid URL, so that problem is solved for me (I
        thought it was JRoller that specified at an admin-level the
        multiple languages option, and so I was stuck with duplicate
        URLs as a result.)

    Yes there are  settings for i18n and the first one is responsible
    for locale to be added to path.


        Internationalization Settings

    I publish my weblog in multiple languages           
    Show my weblog entries from all languages on my homepage    



        I guess we can keep adding the /lang/ portion then, the idea
        is that you can tell people to go to
        http://www.jroller.com/gmazza/en/entry to see English articles
and http://www.jroller.com/gmazza/de/entry to see German ones.
    And to see translated UI. I am considering making the patch
    simpler and strip out the part which enables choosing language.
    Searches will be always made based on current locale or lack of
    locale.

         I personally would rather do separate blogs
        http://www.jroller.com/gmazza and
        http://www.jroller.com/gmazza_de to keep the URLs simpler.
         What do you expect to be doing for your own blog?

    I am thinking about this one also but first I saw the options in
    Weblog settings and tried to make it works. The design for a
    site/blog is not yet finished, but whatever solution I choose the
    site will be up and running in two weeks. So you can see it online.



            I think it's also a poor idea to blog in different
            languages within the same blog (instead of having two
            blogs in two different languages, as Roller fully supports
            individual users creating multiple blogs) because with a
            blog you're trying to create a warm friendly connection
            with your readers, but it's off-putting to your readers
            when you're blogging frequently in a language they can't
            understand.  WDYT?

    That's why I want to separate languages on site and have
    translated UI.

    Maciej



Reply via email to