Ejemplo n.º 1
0
    /// <summary>
    /// 统计需要本地化的行数
    /// </summary>
    /// <param name="filteredStr"></param>
    private void CalculateFileLines(string filteredStr)
    {
        long lineCount = 0;

        m_FilteredPathList.Clear();
        string[] guids = AssetDatabase.FindAssets(filteredStr);
        foreach (var guid in guids)
        {
            string path = AssetDatabase.GUIDToAssetPath(guid);
            if (true)
            {
                string fullPath = Path.Combine(System.Environment.CurrentDirectory, path);
                string text     = System.IO.File.ReadAllText(fullPath);
                if (!string.IsNullOrEmpty(text))
                {
                    if (fullPath.EndsWith("prefab") || fullPath.EndsWith("unity"))
                    {
                        foreach (var line in text.Split('\n'))
                        {
                            if (JpUtil.PlainText_IsContainsJapanese(line))
                            {
                                lineCount++;
                            }
                        }
                    }
                    else                        //text or script
                    {
                        //clear the comment lines
                        text = JpUtil.CleanCommentLines(text);
                        foreach (var line in text.Split('\n'))
                        {
                            if (JpUtil.IsContainsJapanese(line))
                            {
                                lineCount++;
                            }
                        }
                    }
                }
            }
        }
        //UnityEditor.UI.LocalizationTextEditor.ClearConsole();
        Debug.LogFormat("Total :<color=white>{0}</color> lines", lineCount);
    }
Ejemplo n.º 2
0
    private void CheckFiles(string filteredStr)
    {
        System.Action <string, int, int> updateProgress = (text, now, max) => {
            EditorUtility.DisplayProgressBar("Check", text, (float)now / (float)max);
        };
        m_FilteredPathList.Clear();
        string[] guids  = AssetDatabase.FindAssets(filteredStr);
        int      length = guids.Length;

        for (int i = 0; i < length; i++)
        {
            string guid = guids[i];
            string path = AssetDatabase.GUIDToAssetPath(guid);

            string fullPath = Path.Combine(System.Environment.CurrentDirectory, path);
            string text     = System.IO.File.ReadAllText(fullPath);
            if (!string.IsNullOrEmpty(text))
            {
                if (fullPath.EndsWith("prefab") || fullPath.EndsWith("unity"))
                {
                    if (JpUtil.PlainText_IsContainsJapanese(text))
                    {
                        m_FilteredPathList.Add(AssetDatabase.GUIDToAssetPath(guid));
                        continue;
                    }
                }
                else                    //text or script
                {
                    //clear the comment lines
                    text = JpUtil.CleanCommentLines(text);
                    if (JpUtil.IsContainsJapanese(text))
                    {
                        m_FilteredPathList.Add(AssetDatabase.GUIDToAssetPath(guid));
                    }
                }
            }

            updateProgress(path, (i + 1), length);
        }
        //UnityEditor.UI.LocalizationTextEditor.ClearConsole();
        Debug.LogFormat("Total :<color=white>{0}</color> files", m_FilteredPathList.Count);
        EditorUtility.ClearProgressBar();
    }