10 Replies Latest reply on Apr 18, 2008 9:55 AM by j-pro

    rich:fileUpload - internationalization method

    j-pro

      Good afternoon, dear RF developers.

      Sorry for such a simple question, but can you please give a little example on this(from RF 3.2.0 developer's guide):

      ...
      The <rich:fileUpload> component allows to use internationalization method to
      redefine and localize the labels. You could use application resource bundle and define
      RICH_FILE_UPLOAD_CANCEL_LABEL, RICH_FILE_UPLOAD_STOP_LABEL,
      RICH_FILE_UPLOAD_ADD_LABEL, RICH_FILE_UPLOAD_UPLOAD_LABEL,
      RICH_FILE_UPLOAD_CLEAR_LABEL, RICH_FILE_UPLOAD_CLEAR_ALL_LABEL,
      RICH_FILE_UPLOAD_PROGRESS_LABEL, RICH_FILE_UPLOAD_SIZE_ERROR_LABLE,
      RICH_FILE_UPLOAD_TRANSFER_ERROR_LABLE,
      RICH_FILE_UPLOAD_ENTRY_STOP_LABEL, RICH_FILE_UPLOAD_ENTRY_CLEAR_LABEL,
      RICH_FILE_UPLOAD_ENTRY_CANCEL_LABEL there.
      ...


      I already use resourse bundle for internationalization, it's like this:
      ...
      
      <a4j:loadBundle basename="lan" var="muiBundle"/>
      
      ...
      
      <h:outputText value="#{muiBundle.persDataInsurance}" />
      
      ...

      these resources are three files: lan_en.properties, lan_ro.properties, lan_ru.properties.

      So is it possible to redefine fileUpload labels using these bundles?

      Thank you very much for your reply.

        • 1. Re: rich:fileUpload - internationalization method
          ilya_shaikovsky

          As for all our components you should define this properties in application bundle or in the packaged bundle with proper name.

          • 2. Re: rich:fileUpload - internationalization method
            j-pro

             

            "ilya_shaikovsky" wrote:
            As for all our components you should define this properties in application bundle or in the packaged bundle with proper name.

            Ilya, would you be so kind to show me small example please? I just have some knowledge of using bundles I've described above and don't know anything YET about what's an application bundle, or "packaged bundle with proper name". Maybe just don't understand, sorry for that.

            Thanks one more time.

            • 3. Re: rich:fileUpload - internationalization method
              ilya_shaikovsky

              certainly, just create property file in your classpath and define it in faces config like:

               <message-bundle>bundleName</message-bundle>
              


              • 4. Re: rich:fileUpload - internationalization method
                j-pro

                Thanks, ilya_shaikovsky, that helped, now I know how to do it.

                I've even made it for my language bundle by just adding:

                <message-bundle>lan</message-bundle>


                So it works now. Thank you very much!

                • 5. Re: rich:fileUpload - internationalization method
                  j-pro

                  But what should I do to make these labels change like all my other text changes when I switch the language by changing the locale from "en" to "ru" for example?

                  I've put all labels in both of lan_ru.properties, and lan_en.properties and defined it in faces-config... but no way...

                  • 6. Re: rich:fileUpload - internationalization method

                    J-Pro,

                    FileUpload has some attributes where you can define you custom label.

                    To provide i18 you can use the following example:
                    ...
                    // loadNundle

                    <fileUpload ... addControlLabel="#{youBundleName.youAddLabel}" />

                    The other way is create you bundle:
                    1. Create package 'org.richfaces.renderkit' in you application.
                    2. Put there 'fileUpload.properties' file with parameters described in spec.

                    • 7. Re: rich:fileUpload - internationalization method
                      j-pro

                       

                      "andrei_exadel" wrote:
                      J-Pro,

                      FileUpload has some attributes where you can define you custom label.

                      To provide i18 you can use the following example:
                      ...
                      // loadNundle

                      <fileUpload ... addControlLabel="#{youBundleName.youAddLabel}" />

                      This way seems to be the thing I need. But if I understood the dev guide right, then there are attributes only for a few controls in a file upload:
                      You could define labels of the component controls with the help of "addControlLabel" ,
                      "clearAllControlLabel" , "clearControlLabel" , "stopEntryControlLabel" , "uploadControlLabel"
                      attributes.

                      There are some more if I use bundles or fileUpload.properties.

                      For example, addControlLabel is for RICH_FILE_UPLOAD_ADD_LABEL, etc., but what attribute should I use for RICH_FILE_UPLOAD_TRANSFER_ERROR_LABLE?

                      "andrei_exadel" wrote:
                      The other way is create you bundle:
                      1. Create package 'org.richfaces.renderkit' in you application.
                      2. Put there 'fileUpload.properties' file with parameters described in spec.

                      That way works, but again - only for one type of labels?(is it possible to define fileUpload_ru.properties and fileUpload_en.properties?)


                      P.S.: By the way - what does mean "i18" in "To provide i18"? :)

                      • 8. Re: rich:fileUpload - internationalization method
                        ronanker

                        i18 or i18n means internationalization

                        also l10n means localization

                        the number corresponds to the number of letters between first and last character of the word...

                        • 9. Re: rich:fileUpload - internationalization method

                           

                          That way works, but again - only for one type of labels?(is it possible to define fileUpload_ru.properties and fileUpload_en.properties?)


                          Yes. Try it.

                          In this case location will be get from request header according to user's location.

                          Also you can manually set up determined location for fileupload using 'locale' attribute.

                          • 10. Re: rich:fileUpload - internationalization method
                            j-pro

                             

                            "andrei_exadel" wrote:
                            That way works, but again - only for one type of labels?(is it possible to define fileUpload_ru.properties and fileUpload_en.properties?)


                            Yes. Try it.

                            In this case location will be get from request header according to user's location.

                            Also you can manually set up determined location for fileupload using 'locale' attribute.


                            YES! :) It works. I set the locale with appropriate fileUpload attribute. I use changed locale variable from my MUI managed bean. It works.

                            Thank you very much for your time and help, Andrei, you helped me much.