الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

تطبيق Internationalization عبر IDE

بدأه kiubo في 8 أبريل 2012 · 3 رد · 529 مشاهدة · في JavaSE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم ورحمة الله وبركاته

سبب كتابة هذا الموضوع هو كالتالي..

مره من المرات كان لدي برنامج يؤدي وظيفة معينه ارد ان اضيف اللغة العربيه عن طريق Internationalization وبعدها قام بتحويل كل نص الي upper case وبعدها لم استطيع ارجاع الكود كما كان سابقاً..

والكود لم يشتغل نهائيا ولكن الحمدلله ااستطعت ارجاع الكود السابق بطريقة صعبه .. عن طريق ال log الموجوده ب netbeanse

ربما لأني لم افهم طبيعة العمل مع Internationalization بالطريقه صحيحه...

من هذا المنطلق اريد النقاط التي استطع السير عليها كي اضمن سير البرنامج بطريق صحيحيه دون مشاكل

مع العلم اني استخدم ال IDE في تصميم الواجهة واريد التطبيق تعدد اللغات بالطريقة هذه..

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * UserInterface.java
 *
 * Created on Apr 8, 2012, 7:46:06 PM
 */

package testexam;

import javax.swing.JOptionPane;

/**
 *
 * @author Home
 */
public class UserInterface extends javax.swing.JFrame {

    /** Creates new form UserInterface */
    public UserInterface() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

        arButton = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        nameTextField = new javax.swing.JTextField();
        jButton1 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        arButton.setText("Arabic");
        arButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                arButtonActionPerformed(evt);
            }
        });

        jButton2.setText("English");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("UserInterface"));

        jLabel1.setText("type your name?");

        jButton1.setText("Ok");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(nameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 227, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 171, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(37, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(191, Short.MAX_VALUE)
                .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(36, 36, 36)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(nameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jButton1)
                .addContainerGap(100, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(arButton, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jButton2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(22, 22, 22))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jButton2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(arButton))
                .addContainerGap(12, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
    }

    private void arButtonActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
    }

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
String name;
        name=nameTextField.getText();
      JOptionPane.showMessageDialog(null,name);
nameTextField.setText("");
        // TODO add your handling code here:
    }

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new UserInterface().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify
    private javax.swing.JButton arButton;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JTextField nameTextField;
    // End of variables declaration

}

هذا كود البرنامج بسط جدا ً وهذا الكود اريد تطبيق اللغة العربيه فيه ..

المستخدم يكتب اسمه ويظهر له رساله بالاسم الذي ادخله

في حال ضغط على زر ال Arabic سيصبح بالعربي

وفي English سيصبح بالانجليزي

انا اعتذر لأن ربما يكون سؤالي غير جيد :sad:

اريد الفهم كي استطيع طبق هذا المفهوم في مشروعي

كن مثل طابع البريد ، التصق بهدفك...حتى تصل الى هناك!

#2

هذا الفيديو كنت قد قومت بعمله سريعا من قبل لاحد الزملاء

اتمنى ان يفيدك

واتمنى ان ذلك يفيدك

/index.php?showtopic=167926&st=40&p=1052441entry1052441

2

Software Developer
Mahmoudkelany.com


 

#3
Mahmoud Kelany كتب:

هذا الفيديو كنت قد قومت بعمله سريعا من قبل لاحد الزملاء

اتمنى ان يفيدك

واتمنى ان ذلك يفيدك

/index.php?showtopic=167926&st=40&p=1052441entry1052441

هذا بالضبط مااريد

جزالك الله خير ..ماشاء لله انت من الاعضاء المميزن بارك الله فيك

شكراً جزيلاً :happy:

كن مثل طابع البريد ، التصق بهدفك...حتى تصل الى هناك!

#4

طبقت ماتعلمته في هذا الفيديو انا جداً سعيده

هذا الملف المصدري لمن اردا الفائده

شكراً جزيلاً لكم جميعاً

Testexam - Copy.zip

كن مثل طابع البريد ، التصق بهدفك...حتى تصل الى هناك!

مواضيع مشابهة